updates user models
This commit is contained in:
@@ -50,10 +50,10 @@ namespace Umbraco.Web.Models.Mapping
|
||||
});
|
||||
|
||||
config.CreateMap<UserInvite, IUser>()
|
||||
.ConstructUsing(invite => new User(invite.Name, invite.Email, invite.Email, Guid.NewGuid().ToString("N")))
|
||||
.ConstructUsing(invite => new User(invite.Name, invite.Email, invite.Email, Guid.NewGuid().ToString("N")))
|
||||
//generate a token for the invite
|
||||
.ForMember(user => user.SecurityStamp, expression => expression.MapFrom(x => (DateTime.Now + x.Email).ToSHA1()))
|
||||
//all invited users will not be approved, completing the invite will approve the user
|
||||
.ForMember(user => user.SecurityStamp, expression => expression.MapFrom(x => (DateTime.Now + x.Email).ToSHA1()))
|
||||
//all invited users will not be approved, completing the invite will approve the user
|
||||
.ForMember(user => user.IsApproved, expression => expression.UseValue(false))
|
||||
.ForMember(user => user.Id, expression => expression.Ignore())
|
||||
.ForMember(user => user.Avatar, expression => expression.Ignore())
|
||||
@@ -84,24 +84,53 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
user.AddGroup(group.ToReadOnlyGroup());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
config.CreateMap<IUserGroup, UserGroupDisplay>()
|
||||
.ForMember(detail => detail.Sections, opt => opt.MapFrom(x => x.AllowedSections))
|
||||
.ForMember(detail => detail.StartContentId, opt => opt.MapFrom(x => applicationContext.Services.EntityService.Get<IContent>(x.StartContentId, false)))
|
||||
.ForMember(detail => detail.StartMediaId, opt => opt.MapFrom(x => applicationContext.Services.EntityService.Get<IMedia>(x.StartMediaId, false)))
|
||||
.ForMember(detail => detail.Notifications, opt => opt.Ignore())
|
||||
config.CreateMap<IReadOnlyUserGroup, UserGroupDisplay>()
|
||||
.ForMember(detail => detail.StartContentId, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.StartMediaId, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Sections, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Notifications, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Udi, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Trashed, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.ParentId, opt => opt.UseValue(-1))
|
||||
.ForMember(detail => detail.Path, opt => opt.MapFrom(user => "-1," + user.Id))
|
||||
.ForMember(detail => detail.AdditionalData, opt => opt.Ignore());
|
||||
.ForMember(detail => detail.Path, opt => opt.MapFrom(userGroup => "-1," + userGroup.Id))
|
||||
.ForMember(detail => detail.AdditionalData, opt => opt.Ignore())
|
||||
.AfterMap((group, display) =>
|
||||
{
|
||||
var allSections = applicationContext.Services.SectionService.GetSections();
|
||||
display.Sections = allSections.Where(x => group.Alias == x.Alias).Select(Mapper.Map<ContentEditing.Section>);
|
||||
|
||||
//applicationContext.Services.EntityService.Get<IContent>(x.StartContentId, false))
|
||||
//applicationContext.Services.EntityService.Get<IMedia>(x.StartMediaId, false))
|
||||
|
||||
});
|
||||
|
||||
config.CreateMap<IUserGroup, UserGroupDisplay>()
|
||||
.ForMember(detail => detail.StartContentId, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.StartMediaId, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Sections, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Notifications, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Udi, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Trashed, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.ParentId, opt => opt.UseValue(-1))
|
||||
.ForMember(detail => detail.Path, opt => opt.MapFrom(userGroup => "-1," + userGroup.Id))
|
||||
.ForMember(detail => detail.AdditionalData, opt => opt.Ignore())
|
||||
.AfterMap((group, display) =>
|
||||
{
|
||||
var allSections = applicationContext.Services.SectionService.GetSections();
|
||||
display.Sections = allSections.Where(x => group.Alias == x.Alias).Select(Mapper.Map<ContentEditing.Section>);
|
||||
|
||||
//applicationContext.Services.EntityService.Get<IContent>(x.StartContentId, false))
|
||||
//applicationContext.Services.EntityService.Get<IMedia>(x.StartMediaId, false))
|
||||
|
||||
});
|
||||
|
||||
config.CreateMap<IUser, UserDisplay>()
|
||||
.ForMember(detail => detail.Avatars, opt => opt.MapFrom(user => user.GetCurrentUserAvatarUrls(applicationContext.Services.UserService, applicationContext.ApplicationCache.RuntimeCache)))
|
||||
.ForMember(detail => detail.Username, opt => opt.MapFrom(user => user.Username))
|
||||
.ForMember(detail => detail.LastLoginDate, opt => opt.MapFrom(user => user.LastLoginDate == default(DateTime) ? null : (DateTime?) user.LastLoginDate))
|
||||
.ForMember(detail => detail.UserGroups, opt => opt.MapFrom(user => user.Groups.Select(x => x.Alias).ToArray()))
|
||||
.ForMember(detail => detail.UserGroups, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.StartContentIds, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.StartMediaIds, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Culture, opt => opt.MapFrom(user => user.GetUserCulture(applicationContext.Services.TextService)))
|
||||
@@ -126,6 +155,9 @@ namespace Umbraco.Web.Models.Mapping
|
||||
var mediaItems = applicationContext.Services.EntityService.GetAll(UmbracoObjectTypes.Document, user.StartContentIds.ToArray());
|
||||
display.StartContentIds = Mapper.Map<IEnumerable<IUmbracoEntity>, IEnumerable<EntityBasic>>(contentItems);
|
||||
display.StartMediaIds = Mapper.Map<IEnumerable<IUmbracoEntity>, IEnumerable<EntityBasic>>(mediaItems);
|
||||
|
||||
display.UserGroups = Mapper.Map<IEnumerable<IReadOnlyUserGroup>, IEnumerable<UserGroupDisplay>>(user.Groups);
|
||||
|
||||
});
|
||||
|
||||
config.CreateMap<IUser, UserDetail>()
|
||||
|
||||
Reference in New Issue
Block a user