From 517dc3abe3a19c2b18700d5f0bbecb81e307e89d Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 22 May 2017 21:23:04 +1000 Subject: [PATCH] updates more user properties --- .../Models/ContentEditing/UserDisplay.cs | 23 +++++++++++++++---- .../Models/Mapping/UserModelMapper.cs | 7 +++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Web/Models/ContentEditing/UserDisplay.cs b/src/Umbraco.Web/Models/ContentEditing/UserDisplay.cs index 1385e395ec..fe1933669b 100644 --- a/src/Umbraco.Web/Models/ContentEditing/UserDisplay.cs +++ b/src/Umbraco.Web/Models/ContentEditing/UserDisplay.cs @@ -1,7 +1,9 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.ComponentModel; using System.Globalization; using System.Runtime.Serialization; +using Umbraco.Core.Models.Membership; namespace Umbraco.Web.Models.ContentEditing { @@ -9,6 +11,7 @@ namespace Umbraco.Web.Models.ContentEditing /// Represents a user that is being edited /// [DataContract(Name = "user", Namespace = "")] + [ReadOnly(true)] public class UserDisplay : EntityBasic, INotificationModel { public UserDisplay() @@ -16,6 +19,21 @@ namespace Umbraco.Web.Models.ContentEditing Notifications = new List(); } + /// + /// The MD5 lowercase hash of the email which can be used by gravatar + /// + [DataMember(Name = "emailHash")] + public string EmailHash { get; set; } + + [DataMember(Name = "lastLoginDate")] + public DateTime LastLoginDate { get; set; } + + [DataMember(Name = "customAvatar")] + public string CustomAvatar { get; set; } + + [DataMember(Name = "userState")] + public UserState UserState { get; set; } + [DataMember(Name = "culture", IsRequired = true)] public string Culture { get; set; } @@ -33,7 +51,6 @@ namespace Umbraco.Web.Models.ContentEditing /// The key is the Alias the value is the Name - the Alias is what is used in the UserGroup property and for persistence /// [DataMember(Name = "availableUserGroups")] - [ReadOnly(true)] public IDictionary AvailableUserGroups { get; set; } /// @@ -41,7 +58,6 @@ namespace Umbraco.Web.Models.ContentEditing /// The key is the culture stored in the database, the value is the Name /// [DataMember(Name = "availableCultures")] - [ReadOnly(true)] public IDictionary AvailableCultures { get; set; } [DataMember(Name = "startContentId")] @@ -61,7 +77,6 @@ namespace Umbraco.Web.Models.ContentEditing /// The key is the Alias the value is the Name - the Alias is what is used in the AllowedSections property and for persistence /// [DataMember(Name = "availableSections")] - [ReadOnly(true)] public IDictionary AvailableSections { get; set; } /// diff --git a/src/Umbraco.Web/Models/Mapping/UserModelMapper.cs b/src/Umbraco.Web/Models/Mapping/UserModelMapper.cs index f58dfe875a..00e8e9a230 100644 --- a/src/Umbraco.Web/Models/Mapping/UserModelMapper.cs +++ b/src/Umbraco.Web/Models/Mapping/UserModelMapper.cs @@ -31,14 +31,19 @@ namespace Umbraco.Web.Models.Mapping .ForMember( detail => detail.AvailableCultures, opt => opt.MapFrom(user => applicationContext.Services.TextService.GetSupportedCultures().ToDictionary(x => x.Name, x => x.DisplayName))) + .ForMember( + detail => detail.EmailHash, + opt => opt.MapFrom(user => user.Email.ToLowerInvariant().Trim().ToMd5())) .ForMember(detail => detail.ParentId, opt => opt.UseValue(-1)) - .ForMember(detail => detail.Path, opt => opt.MapFrom(user => "-1," + user.Id)) + .ForMember(detail => detail.Path, opt => opt.MapFrom(user => "-1," + user.Id)) .ForMember(detail => detail.Notifications, opt => opt.Ignore()) .ForMember(detail => detail.Udi, opt => opt.Ignore()) .ForMember(detail => detail.Icon, opt => opt.Ignore()) .ForMember(detail => detail.Trashed, opt => opt.Ignore()) .ForMember(detail => detail.Alias, opt => opt.Ignore()) .ForMember(detail => detail.Trashed, opt => opt.Ignore()) + //TODO: Enable this when we can! + .ForMember(detail => detail.CustomAvatar, opt => opt.Ignore()) .ForMember(detail => detail.AdditionalData, opt => opt.Ignore()); config.CreateMap()