It builds!

This commit is contained in:
Shannon
2017-05-04 19:16:52 +10:00
parent 24e2547656
commit 8f69efe331
16 changed files with 121 additions and 151 deletions

View File

@@ -85,7 +85,7 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
//46, removed: UmbracoDeployChecksumDto
//47, removed: UmbracoDeployDependencyDto
{48, typeof (RedirectUrlDto) },
{49, typeof (LockDto) }
{49, typeof (LockDto) },
{49, typeof (UserGroupDto) },
{50, typeof (User2UserGroupDto) },
{51, typeof (UserGroup2NodePermissionDto) },

View File

@@ -1,13 +1,13 @@
using System;
using System.Data;
using System.Linq;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence.SqlSyntax;
using System.Data;
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenSixZero
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenSevenZero
{
[Migration("7.6.0", 100, GlobalSettings.UmbracoMigrationName)]
[Migration("7.6.0", 100, Constants.System.UmbracoMigrationName)]
public class AddUserGroupTables : MigrationBase
{
public AddUserGroupTables(ISqlSyntaxProvider sqlSyntax, ILogger logger)

View File

@@ -1,7 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Dynamic;
using System.Globalization;
using System.Linq;
using System.Text;
@@ -12,18 +10,8 @@ using Umbraco.Core.Models.Membership;
using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Persistence.UnitOfWork;
using Umbraco.Core.Services;
using CacheKeys = Umbraco.Core.Cache.CacheKeys;
using Umbraco.Core.Cache;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Persistence.UnitOfWork;
namespace Umbraco.Core.Persistence.Repositories
{
@@ -67,8 +55,8 @@ namespace Umbraco.Core.Persistence.Repositories
sql.Select("*")
.From<UserGroup2NodePermissionDto>()
.Where(whereCriteria);
var result = _unitOfWork.Database.Fetch<UserGroup2NodePermissionDto>(sql).ToArray();
// ToArray() to ensure it's all fetched from the db once
var result = _unitOfWork.Database.Fetch<UserGroup2NodePermissionDto>(sql).ToArray();
// ToArray() to ensure it's all fetched from the db once
return ConvertToPermissionList(result);
},
GetCacheTimeout(),
@@ -154,8 +142,8 @@ namespace Umbraco.Core.Persistence.Repositories
.Where<UserGroup2NodePermissionDto>(dto => dto.NodeId == entityId)
.OrderBy<UserGroup2NodePermissionDto>(dto => dto.NodeId);
var result = _unitOfWork.Database.Fetch<UserGroup2NodePermissionDto>(sql).ToArray();
// ToArray() to ensure it's all fetched from the db once
var result = _unitOfWork.Database.Fetch<UserGroup2NodePermissionDto>(sql).ToArray();
// ToArray() to ensure it's all fetched from the db once
return ConvertToPermissionList(result);
}
@@ -170,37 +158,34 @@ namespace Umbraco.Core.Persistence.Repositories
/// </remarks>
public void ReplacePermissions(int groupId, IEnumerable<char> permissions, params int[] entityIds)
{
var db = _unitOfWork.Database;
//we need to batch these in groups of 2000 so we don't exceed the max 2100 limit
var sql = "DELETE FROM umbracoUserGroup2NodePermission WHERE userGroupId = @groupId AND nodeId in (@nodeIds)";
var db = _unitOfWork.Database;
//we need to batch these in groups of 2000 so we don't exceed the max 2100 limit
var sql = "DELETE FROM umbracoUserGroup2NodePermission WHERE userGroupId = @groupId AND nodeId in (@nodeIds)";
foreach (var idGroup in entityIds.InGroupsOf(2000))
{
db.Execute(sql, new {groupId = groupId, nodeIds = idGroup});
}
var toInsert = new List<UserGroup2NodePermissionDto>();
{
db.Execute(sql, new { groupId = groupId, nodeIds = idGroup });
}
var toInsert = new List<UserGroup2NodePermissionDto>();
foreach (var p in permissions)
{
foreach (var e in entityIds)
{
toInsert.Add(new UserGroup2NodePermissionDto
{
toInsert.Add(new UserGroup2NodePermissionDto
{
NodeId = e,
Permission = p.ToString(CultureInfo.InvariantCulture),
UserGroupId = groupId
Permission = p.ToString(CultureInfo.InvariantCulture),
UserGroupId = groupId
});
}
}
_unitOfWork.Database.BulkInsertRecords(toInsert, _sqlSyntax);
//Raise the event
//TODO: FIX THIS
_unitOfWork.Events.Dispatch(AssignedPermissions, this, new SaveEventArgs<EntityPermission>(ConvertToPermissionList(toInsert), false));
AssignedPermissions.RaiseEvent(
new SaveEventArgs<UserGroupEntityPermission>(ConvertToPermissionList(toInsert), false), this)
_unitOfWork.Database.BulkInsertRecords(toInsert, _sqlSyntax);
//Raise the event
_unitOfWork.Events.Dispatch(AssignedPermissions, this, new SaveEventArgs<UserGroupEntityPermission>(ConvertToPermissionList(toInsert), false));
}
/// <summary>
@@ -211,30 +196,27 @@ namespace Umbraco.Core.Persistence.Repositories
/// <param name="entityIds"></param>
public void AssignPermission(int groupId, char permission, params int[] entityIds)
{
var db = _unitOfWork.Database;
var sql = "DELETE FROM umbracoUserGroup2NodePermission WHERE userGroupId = @groupId AND permission=@permission AND nodeId in (@entityIds)";
db.Execute(sql,
new
{
groupId = groupId,
permission = permission.ToString(CultureInfo.InvariantCulture),
entityIds = entityIds
});
var actions = entityIds.Select(id => new UserGroup2NodePermissionDto
var db = _unitOfWork.Database;
var sql = "DELETE FROM umbracoUserGroup2NodePermission WHERE userGroupId = @groupId AND permission=@permission AND nodeId in (@entityIds)";
db.Execute(sql,
new
{
groupId = groupId,
permission = permission.ToString(CultureInfo.InvariantCulture),
entityIds = entityIds
});
var actions = entityIds.Select(id => new UserGroup2NodePermissionDto
{
NodeId = id,
Permission = permission.ToString(CultureInfo.InvariantCulture),
UserGroupId = groupId
Permission = permission.ToString(CultureInfo.InvariantCulture),
UserGroupId = groupId
}).ToArray();
_unitOfWork.Database.BulkInsertRecords(actions, _sqlSyntax);
//Raise the event
//TODO: Fix this
_unitOfWork.Events.Dispatch(AssignedPermissions, this, new SaveEventArgs<EntityPermission>(ConvertToPermissionList(actions), false));
AssignedPermissions.RaiseEvent(
new SaveEventArgs<UserGroupEntityPermission>(ConvertToPermissionList(actions), false), this)
_unitOfWork.Database.BulkInsertRecords(actions, _sqlSyntax);
//Raise the event
_unitOfWork.Events.Dispatch(AssignedPermissions, this, new SaveEventArgs<UserGroupEntityPermission>(ConvertToPermissionList(actions), false));
}
@@ -246,31 +228,28 @@ namespace Umbraco.Core.Persistence.Repositories
/// <param name="groupIds"></param>
public void AssignEntityPermission(TEntity entity, char permission, IEnumerable<int> groupIds)
{
var db = _unitOfWork.Database;
var sql = "DELETE FROM umbracoUserGroup2NodePermission WHERE nodeId = @nodeId AND permission = @permission AND userGroupId in (@groupIds)";
db.Execute(sql,
new
{
nodeId = entity.Id,
permission = permission.ToString(CultureInfo.InvariantCulture),
groupIds = groupIds
});
var actions = groupIds.Select(id => new UserGroup2NodePermissionDto
var db = _unitOfWork.Database;
var sql = "DELETE FROM umbracoUserGroup2NodePermission WHERE nodeId = @nodeId AND permission = @permission AND userGroupId in (@groupIds)";
db.Execute(sql,
new
{
nodeId = entity.Id,
permission = permission.ToString(CultureInfo.InvariantCulture),
groupIds = groupIds
});
var actions = groupIds.Select(id => new UserGroup2NodePermissionDto
{
NodeId = entity.Id,
Permission = permission.ToString(CultureInfo.InvariantCulture),
UserGroupId = id
Permission = permission.ToString(CultureInfo.InvariantCulture),
UserGroupId = id
}).ToArray();
_unitOfWork.Database.BulkInsertRecords(actions, _sqlSyntax);
//Raise the event
//TODO: Fix this
_unitOfWork.Events.Dispatch(AssignedPermissions, this, new SaveEventArgs<EntityPermission>(ConvertToPermissionList(actions), false));
AssignedPermissions.RaiseEvent(
new SaveEventArgs<UserGroupEntityPermission>(ConvertToPermissionList(actions), false), this)
_unitOfWork.Events.Dispatch(AssignedPermissions, this, new SaveEventArgs<UserGroupEntityPermission>(ConvertToPermissionList(actions), false));
}
/// <summary>
@@ -283,26 +262,23 @@ namespace Umbraco.Core.Persistence.Repositories
/// </remarks>
public void ReplaceEntityPermissions(EntityPermissionSet permissionSet)
{
var db = _unitOfWork.Database;
var sql = "DELETE FROM umbracoUserGroup2NodePermission WHERE nodeId = @nodeId";
db.Execute(sql, new {nodeId = permissionSet.EntityId});
var actions = permissionSet.PermissionsSet.Select(p => new UserGroup2NodePermissionDto
var db = _unitOfWork.Database;
var sql = "DELETE FROM umbracoUserGroup2NodePermission WHERE nodeId = @nodeId";
db.Execute(sql, new { nodeId = permissionSet.EntityId });
var actions = permissionSet.PermissionsSet.Select(p => new UserGroup2NodePermissionDto
{
NodeId = permissionSet.EntityId,
Permission = p.Permission,
UserGroupId = p.UserGroupId
Permission = p.Permission,
UserGroupId = p.UserGroupId
}).ToArray();
_unitOfWork.Database.BulkInsertRecords(actions, _sqlSyntax);
//Raise the event
//TODO: Fix this
_unitOfWork.Events.Dispatch(AssignedPermissions, this, new SaveEventArgs<EntityPermission>(ConvertToPermissionList(actions), false));
AssignedPermissions.RaiseEvent(
new SaveEventArgs<UserGroupEntityPermission>(ConvertToPermissionList(actions), false), this)
}
_unitOfWork.Database.BulkInsertRecords(actions, _sqlSyntax);
//Raise the event
_unitOfWork.Events.Dispatch(AssignedPermissions, this, new SaveEventArgs<UserGroupEntityPermission>(ConvertToPermissionList(actions), false));
}
public static event TypedEventHandler<PermissionRepository<TEntity>, SaveEventArgs<UserGroupEntityPermission>> AssignedPermissions;

View File

@@ -20,7 +20,7 @@ namespace Umbraco.Core.Persistence.Repositories
{
private readonly CacheHelper _cacheHelper;
public UserGroupRepository(IDatabaseUnitOfWork work, CacheHelper cacheHelper, ILogger logger, ISqlSyntaxProvider sqlSyntax)
public UserGroupRepository(IScopeUnitOfWork work, CacheHelper cacheHelper, ILogger logger, ISqlSyntaxProvider sqlSyntax)
: base(work, cacheHelper, logger, sqlSyntax)
{
_cacheHelper = cacheHelper;

View File

@@ -20,12 +20,12 @@ namespace Umbraco.Core.Persistence.Repositories
/// </summary>
internal class UserRepository : PetaPocoRepositoryBase<int, IUser>, IUserRepository
{
private readonly CacheHelper _cacheHelper;
//private readonly CacheHelper _cacheHelper;
public UserRepository(IDatabaseUnitOfWork work, CacheHelper cacheHelper, ILogger logger, ISqlSyntaxProvider sqlSyntax)
public UserRepository(IScopeUnitOfWork work, CacheHelper cacheHelper, ILogger logger, ISqlSyntaxProvider sqlSyntax)
: base(work, cacheHelper, logger, sqlSyntax)
{
_cacheHelper = cacheHelper;
//_cacheHelper = cacheHelper;
}
#region Overrides of RepositoryBase<int,IUser>

View File

@@ -612,7 +612,7 @@ namespace Umbraco.Core.Services
{
using (var uow = UowProvider.GetUnitOfWork())
{
var repository = RepositoryFactory.CreateUserGroupRepository(uow)
var repository = RepositoryFactory.CreateUserGroupRepository(uow);
repository.AssignGroupPermission(groupId, permission, entityIds);
uow.Commit();
}
@@ -641,7 +641,7 @@ namespace Umbraco.Core.Services
{
using (var uow = UowProvider.GetUnitOfWork(readOnly: true))
{
var repository = RepositoryFactory.CreateUserGroupRepository(uow);
var repository = RepositoryFactory.CreateUserRepository(uow);
return repository.GetGroupsForUser(userId);
}
}
@@ -653,9 +653,12 @@ namespace Umbraco.Core.Services
/// <returns><see cref="IUserGroup"/></returns>
public IUserGroup GetUserGroupByAlias(string alias)
{
using (var repository = RepositoryFactory.CreateUserGroupRepository(UowProvider.GetUnitOfWork()))
using (var uow = UowProvider.GetUnitOfWork(readOnly: true))
{
var repository = RepositoryFactory.CreateUserGroupRepository(uow);
var query = Query<IUserGroup>.Builder.Where(x => x.Alias == alias);
var contents = repository.GetByQuery(query);
return contents.SingleOrDefault();
}
}
@@ -682,7 +685,7 @@ namespace Umbraco.Core.Services
{
using (var uow = UowProvider.GetUnitOfWork(readOnly: true))
{
var repository = RepositoryFactory.CreateUserGroupRepository(uow)
var repository = RepositoryFactory.CreateUserGroupRepository(uow);
var query = Query<IUserGroup>.Builder.Where(x => x.Name == name);
return repository.GetByQuery(query).SingleOrDefault();
}
@@ -835,7 +838,7 @@ namespace Umbraco.Core.Services
public IEnumerable<EntityPermission> GetPermissions(IUserGroup group, bool directlyAssignedOnly, params int[] nodeIds)
{
using (var uow = UowProvider.GetUnitOfWork();)
using (var uow = UowProvider.GetUnitOfWork(readOnly: true))
{
var repository = RepositoryFactory.CreateUserGroupRepository(uow);
var explicitPermissions = repository.GetPermissionsForEntities(group.Id, nodeIds);
@@ -951,11 +954,11 @@ namespace Umbraco.Core.Services
: int.Parse(path);
}
private static bool IsNotNullActionPermission(EntityPermission x)
{
const string NullActionChar = "-";
return string.Join(string.Empty, x.AssignedPermissions) != NullActionChar;
}
//private static bool IsNotNullActionPermission(EntityPermission x)
//{
// const string NullActionChar = "-";
// return string.Join(string.Empty, x.AssignedPermissions) != NullActionChar;
//}
/// <summary>
/// Checks in a set of permissions associated with a user for those related to a given nodeId

View File

@@ -521,13 +521,13 @@
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenFourZero\AddUniqueIdPropertyTypeGroupColumn.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenFourZero\RemoveParentIdPropertyTypeGroupColumn.cs" />
<Compile Include="Persistence\Mappers\TaskTypeMapper.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenSevenZero\AddUserGroupTables.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenSixZero\AddIndexToCmsMemberLoginName.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenSixZero\AddIndexesToUmbracoRelationTables.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenSixZero\AddIndexToUmbracoNodePath.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenSixZero\AddIndexToUser2NodePermission.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenSixZero\AddRelationTypeUniqueIdColumn.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenSixZero\AddMacroUniqueIdColumn.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenSevenZero\AddUserGroupTables.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenSixZero\ReduceLoginNameColumnsSize.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenSixZero\NormalizeTemplateGuids.cs" />
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenSixZero\RemovePropertyDataIdIndex.cs" />

View File

@@ -32,8 +32,8 @@ namespace Umbraco.Tests.Cache
new EventDefinition<ISectionService, EventArgs>(null, ServiceContext.SectionService, new EventArgs(), "Deleted"),
new EventDefinition<ISectionService, EventArgs>(null, ServiceContext.SectionService, new EventArgs(), "New"),
new EventDefinition<IUserService, SaveEventArgs<IUserType>>(null, ServiceContext.UserService, new SaveEventArgs<IUserType>(Enumerable.Empty<IUserType>())),
new EventDefinition<IUserService, DeleteEventArgs<IUserType>>(null, ServiceContext.UserService, new DeleteEventArgs<IUserType>(Enumerable.Empty<IUserType>())),
new EventDefinition<IUserService, SaveEventArgs<IUserGroup>>(null, ServiceContext.UserService, new SaveEventArgs<IUserGroup>(Enumerable.Empty<IUserGroup>())),
new EventDefinition<IUserService, DeleteEventArgs<IUserGroup>>(null, ServiceContext.UserService, new DeleteEventArgs<IUserGroup>(Enumerable.Empty<IUserGroup>())),
new EventDefinition<IUserService, SaveEventArgs<IUser>>(null, ServiceContext.UserService, new SaveEventArgs<IUser>(Enumerable.Empty<IUser>())),
new EventDefinition<IUserService, DeleteEventArgs<IUser>>(null, ServiceContext.UserService, new DeleteEventArgs<IUser>(Enumerable.Empty<IUser>())),

View File

@@ -64,7 +64,7 @@ namespace Umbraco.Tests.Persistence.Repositories
return repository;
}
private UserGroupRepository CreateUserGroupRepository(IDatabaseUnitOfWork unitOfWork)
private UserGroupRepository CreateUserGroupRepository(IScopeUnitOfWork unitOfWork)
{
return new UserGroupRepository(unitOfWork, CacheHelper, Logger, SqlSyntax);
}

View File

@@ -30,7 +30,7 @@ namespace Umbraco.Tests.Persistence.Repositories
base.TearDown();
}
private UserGroupRepository CreateRepository(IDatabaseUnitOfWork unitOfWork)
private UserGroupRepository CreateRepository(IScopeUnitOfWork unitOfWork)
{
return new UserGroupRepository(unitOfWork, CacheHelper.CreateDisabledCacheHelper(), Mock.Of<ILogger>(), SqlSyntax);
}

View File

@@ -28,14 +28,13 @@ namespace Umbraco.Tests.Persistence.Repositories
base.TearDown();
}
private UserRepository CreateRepository(IScopeUnitOfWork unitOfWork, out UserTypeRepository userTypeRepository)
private UserRepository CreateRepository(IScopeUnitOfWork unitOfWork)
{
userTypeRepository = new UserTypeRepository(unitOfWork, CacheHelper.CreateDisabledCacheHelper(), Mock.Of<ILogger>(), SqlSyntax);
var repository = new UserRepository(unitOfWork, CacheHelper.CreateDisabledCacheHelper(), Mock.Of<ILogger>(), SqlSyntax, userTypeRepository);
var repository = new UserRepository(unitOfWork, CacheHelper.CreateDisabledCacheHelper(), Mock.Of<ILogger>(), SqlSyntax);
return repository;
}
private UserGroupRepository CreateUserGroupRepository(IDatabaseUnitOfWork unitOfWork)
private UserGroupRepository CreateUserGroupRepository(IScopeUnitOfWork unitOfWork)
{
return new UserGroupRepository(unitOfWork, CacheHelper.CreateDisabledCacheHelper(), Mock.Of<ILogger>(), SqlSyntax);
}

View File

@@ -80,8 +80,7 @@ namespace Umbraco.Tests.Scoping
var service = ApplicationContext.Services.UserService;
var globalCache = ApplicationContext.ApplicationCache.IsolatedRuntimeCache.GetOrCreateCache(typeof(IUser));
var userType = service.GetUserTypeByAlias("admin");
var user = (IUser) new User("name", "email", "username", "rawPassword", userType);
var user = (IUser) new User("name", "email", "username", "rawPassword");
service.Save(user);
// global cache contains the entity

View File

@@ -535,11 +535,10 @@ namespace Umbraco.Tests.Services
public void Cannot_Create_User_With_Empty_Username()
{
// Arrange
var userService = ServiceContext.UserService;
var userType = userService.GetUserTypeByAlias("admin");
var userService = ServiceContext.UserService;
// Act & Assert
Assert.Throws<ArgumentException>(() => userService.CreateUserWithIdentity(string.Empty, "john@umbraco.io", userType));
Assert.Throws<ArgumentException>(() => userService.CreateUserWithIdentity(string.Empty, "john@umbraco.io"));
}
[Test]
@@ -547,8 +546,7 @@ namespace Umbraco.Tests.Services
{
// Arrange
var userService = ServiceContext.UserService;
var userType = userService.GetUserTypeByAlias("admin");
var user = userService.CreateUserWithIdentity("John Doe", "john@umbraco.io", userType);
var user = userService.CreateUserWithIdentity("John Doe", "john@umbraco.io");
user.Username = string.Empty;
// Act & Assert
@@ -560,8 +558,7 @@ namespace Umbraco.Tests.Services
{
// Arrange
var userService = ServiceContext.UserService;
var userType = userService.GetUserTypeByAlias("admin");
var user = userService.CreateUserWithIdentity("John Doe", "john@umbraco.io", userType);
var user = userService.CreateUserWithIdentity("John Doe", "john@umbraco.io");
user.Name = string.Empty;
// Act & Assert

View File

@@ -58,30 +58,12 @@ namespace Umbraco.Web.Cache
() => SectionService.Deleted -= SectionService_Deleted);
Bind(() => SectionService.New += SectionService_New,
() => SectionService.New -= SectionService_New);
//bind to user / user group events
//TODO: FIX THIS
UserService.SavedUserGroup += UserServiceSavedUserGroup;
UserService.DeletedUserGroup += UserServiceDeletedUserGroup;
UserService.SavedUser += UserServiceSavedUser;
UserService.DeletedUser += UserServiceDeletedUser;
//Bind to dictionary events
LocalizationService.DeletedDictionaryItem += LocalizationServiceDeletedDictionaryItem;
LocalizationService.SavedDictionaryItem += LocalizationServiceSavedDictionaryItem;
//Bind to data type events
//NOTE: we need to bind to legacy and new API events currently: http://issues.umbraco.org/issue/U4-1979
DataTypeService.Deleted += DataTypeServiceDeleted;
DataTypeService.Saved += DataTypeServiceSaved
//END FIX THIS
// bind to user and user type events
Bind(() => UserService.SavedUserType += UserService_SavedUserType,
() => UserService.SavedUserType -= UserService_SavedUserType);
Bind(() => UserService.DeletedUserType += UserService_DeletedUserType,
() => UserService.DeletedUserType -= UserService_DeletedUserType);
Bind(() => UserService.SavedUserGroup += UserServiceSavedUserGroup,
() => UserService.SavedUserGroup -= UserServiceSavedUserGroup);
Bind(() => UserService.DeletedUserGroup += UserServiceDeletedUserGroup,
() => UserService.DeletedUserGroup -= UserServiceDeletedUserGroup);
Bind(() => UserService.SavedUser += UserService_SavedUser,
() => UserService.SavedUser -= UserService_SavedUser);
Bind(() => UserService.DeletedUser += UserService_DeletedUser,

View File

@@ -443,6 +443,8 @@
<Compile Include="umbraco.presentation\SafeXmlReaderWriter.cs" />
<Compile Include="Trees\ScriptTreeController.cs" />
<Compile Include="umbraco.presentation\umbraco\developer\Packages\installer.aspx.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="umbraco.presentation\umbraco\Trees\UserGroups.cs" />
<Compile Include="umbraco.presentation\umbraco\users\EditUserGroup.aspx.cs">
<DependentUpon>EditUserGroup.aspx</DependentUpon>

View File

@@ -25,6 +25,7 @@ using Umbraco.Core.Models;
using PropertyType = umbraco.cms.businesslogic.propertytype.PropertyType;
using System.Text.RegularExpressions;
using System.Text;
using Umbraco.Core.Security;
namespace umbraco.cms.presentation.user
{
@@ -62,7 +63,7 @@ namespace umbraco.cms.presentation.user
protected DropDownList cExcerpt = new DropDownList();
protected ContentPicker cMediaPicker = new ContentPicker();
protected ContentPicker cContentPicker = new ContentPicker();
protected CustomValidator sectionValidator = new CustomValidator();
//protected CustomValidator sectionValidator = new CustomValidator();
protected UpdatePanel pnlGroups = new UpdatePanel();
protected PlaceHolder pnlGroupControls = new PlaceHolder();
@@ -294,6 +295,17 @@ namespace umbraco.cms.presentation.user
ClientTools
.SetActiveTreeType(TreeDefinitionCollection.Instance.FindTree<loadUsers>().Tree.Alias)
.SyncTree(UID.ToString(), IsPostBack);
}
private void LnameCustomValidator_OnServerValidate(object source, ServerValidateEventArgs args)
{
var usersWithLoginName = ApplicationContext.Services.UserService.GetByUsername(lname.Text);
args.IsValid = usersWithLoginName == null || usersWithLoginName.Id == u.Id;
}
private void EmailCustomValidator_OnServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = MembershipProviderBase.IsEmailValid(email.Text.Trim());
}
private void BindGroups()