using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNet.Identity; using Umbraco.Core.Security; namespace Umbraco.Core.Models.Identity { public class BackOfficeIdentityUser : IdentityUser, IdentityUserClaim> { public virtual async Task GenerateUserIdentityAsync(BackOfficeUserManager manager) { // NOTE the authenticationType must match the umbraco one // defined in CookieAuthenticationOptions.AuthenticationType var userIdentity = await manager.CreateIdentityAsync(this, Constants.Security.BackOfficeAuthenticationType); return userIdentity; } /// /// Gets/sets the user's real name /// public string Name { get; set; } public int StartContentId { get; set; } public int StartMediaId { get; set; } public string[] AllowedSections { get; set; } public string Culture { get; set; } public string UserTypeAlias { get; set; } /// /// Overridden to make the retrieval lazy /// public override ICollection Logins { get { if (_getLogins != null && _getLogins.IsValueCreated == false) { _logins = new ObservableCollection(); foreach (var l in _getLogins.Value) { _logins.Add(l); } //now assign events _logins.CollectionChanged += Logins_CollectionChanged; } return _logins; } } public bool LoginsChanged { get; private set; } void Logins_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { LoginsChanged = true; } private ObservableCollection _logins; private Lazy> _getLogins; /// /// Used to set a lazy call back to populate the user's Login list /// /// public void SetLoginsCallback(Lazy> callback) { if (callback == null) throw new ArgumentNullException("callback"); _getLogins = callback; } } }