updates more user properties

This commit is contained in:
Shannon
2017-05-22 21:23:04 +10:00
parent 48432179be
commit 517dc3abe3
2 changed files with 25 additions and 5 deletions

View File

@@ -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
/// </summary>
[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<Notification>();
}
/// <summary>
/// The MD5 lowercase hash of the email which can be used by gravatar
/// </summary>
[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
/// </summary>
[DataMember(Name = "availableUserGroups")]
[ReadOnly(true)]
public IDictionary<string, string> AvailableUserGroups { get; set; }
/// <summary>
@@ -41,7 +58,6 @@ namespace Umbraco.Web.Models.ContentEditing
/// The key is the culture stored in the database, the value is the Name
/// </summary>
[DataMember(Name = "availableCultures")]
[ReadOnly(true)]
public IDictionary<string, string> 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
/// </summary>
[DataMember(Name = "availableSections")]
[ReadOnly(true)]
public IDictionary<string, string> AvailableSections { get; set; }
/// <summary>

View File

@@ -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<IUser, UserDetail>()