Class UmbracoIdentityUser
Abstract class for use in Umbraco Identity for users and members
Inheritance
Namespace: Umbraco.Cms.Core.Security
Assembly: Umbraco.Infrastructure.dll
Syntax
public abstract class UmbracoIdentityUser : IdentityUser, IRememberBeingDirty, ICanBeDirty
Remarks
This uses strings for the ID of the user, claims, roles. This is because aspnetcore identity's base store will not support having an INT user PK and a string role PK with the way they've made the generics. So we will just use string for both which makes things more flexible anyways for users and members and also if/when we transition to GUID support
This class was originally borrowed from the EF implementation in Identity prior to netcore. The new IdentityUser in netcore does not have properties such as Claims, Roles and Logins and those are instead by default managed with their default user store backed by EF which utilizes EF's change tracking to track these values to a user. We will continue using this approach since it works fine for what we need which does the change tracking of claims, roles and logins directly on the user model.
Constructors
View SourceUmbracoIdentityUser()
Initializes a new instance of the UmbracoIdentityUser class.
Declaration
public UmbracoIdentityUser()
Properties
View SourceAccessFailedCount
Gets or sets the value to record failures for the purposes of lockout
Declaration
public override int AccessFailedCount { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
BeingDirty
Gets the BeingDirty for change tracking
Declaration
protected BeingDirty BeingDirty { get; }
Property Value
| Type | Description |
|---|---|
| BeingDirty |
Claims
Gets navigation the user claims collection
Declaration
public ICollection<IdentityUserClaim<string>> Claims { get; }
Property Value
| Type | Description |
|---|---|
| ICollection<IdentityUserClaim<System.String>> |
ConcurrencyStamp
Declaration
public override string ConcurrencyStamp { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Gets or sets email
Declaration
public override string Email { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
EmailConfirmed
Gets or sets a value indicating whether the email is confirmed, default is false
Declaration
public override bool EmailConfirmed { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
HasIdentity
Gets or sets a value indicating whether returns an Id has been set on this object this will be false if the object is new and not persisted to the database
Declaration
public bool HasIdentity { get; protected set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Id
Gets or sets user ID (Primary Key)
Declaration
public override string Id { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
IsApproved
Gets or sets a value indicating whether the IUser IsApproved
Declaration
public bool IsApproved { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsLockedOut
Gets a value indicating whether the user is locked out based on the user's lockout end date
Declaration
public bool IsLockedOut { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
LastLoginDateUtc
Gets or sets last login date
Declaration
public DateTime? LastLoginDateUtc { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Nullable<DateTime> |
LastPasswordChangeDateUtc
Gets or sets dateTime in UTC when the password was last changed.
Declaration
public DateTime? LastPasswordChangeDateUtc { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Nullable<DateTime> |
LockoutEnabled
Gets or sets a value indicating whether is lockout enabled for this user
Declaration
public override bool LockoutEnabled { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Currently this is always true for users and members
Logins
Gets the user logins collection
Declaration
public ICollection<IIdentityUserLogin> Logins { get; }
Property Value
| Type | Description |
|---|---|
| ICollection<IIdentityUserLogin> |
LoginTokens
Gets the external login tokens collection
Declaration
public ICollection<IIdentityUserToken> LoginTokens { get; }
Property Value
| Type | Description |
|---|---|
| ICollection<IIdentityUserToken> |
Name
Gets or sets the user's real name
Declaration
public string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
PasswordConfig
Gets or sets the password config
Declaration
public string PasswordConfig { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
PasswordHash
Gets or sets the salted/hashed form of the user password
Declaration
public override string PasswordHash { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Roles
Gets or sets the user roles collection
Declaration
public ICollection<IdentityUserRole<string>> Roles { get; set; }
Property Value
| Type | Description |
|---|---|
| ICollection<IdentityUserRole<System.String>> |
UserName
Gets or sets user name
Declaration
public override string UserName { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
View SourceAddRole(String)
Adds a role
Declaration
public void AddRole(string role)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | role | The role to add |
Remarks
Adding a role this way will not reflect on the user's group's collection or it's allowed sections until the user is persisted
DisableChangeTracking()
Disables change tracking.
Declaration
public void DisableChangeTracking()
EnableChangeTracking()
Enables change tracking.
Declaration
public void EnableChangeTracking()
GetDirtyProperties()
Declaration
public IEnumerable<string> GetDirtyProperties()
Returns
| Type | Description |
|---|---|
| IEnumerable<System.String> |
GetWereDirtyProperties()
Declaration
public IEnumerable<string> GetWereDirtyProperties()
Returns
| Type | Description |
|---|---|
| IEnumerable<System.String> |
IsDirty()
Determines whether the current entity is dirty.
Declaration
public bool IsDirty()
Returns
| Type | Description |
|---|---|
| System.Boolean |
IsPropertyDirty(String)
Determines whether a specific property is dirty.
Declaration
public bool IsPropertyDirty(string propName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | propName |
Returns
| Type | Description |
|---|---|
| System.Boolean |
ResetDirtyProperties()
Resets dirty properties.
Declaration
public void ResetDirtyProperties()
ResetDirtyProperties(Boolean)
Resets dirty properties.
Declaration
public void ResetDirtyProperties(bool rememberDirty)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | rememberDirty | A value indicating whether to remember dirty properties. |
Remarks
When rememberDirty is true, dirty properties are saved so they can be checked with
WasDirty.
ResetWereDirtyProperties()
Resets properties that were dirty.
Declaration
public void ResetWereDirtyProperties()
WasDirty()
Determines whether the current entity is dirty.
Declaration
public bool WasDirty()
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
A property was dirty if it had been changed and the changes were committed.
WasPropertyDirty(String)
Determines whether a specific property was dirty.
Declaration
public bool WasPropertyDirty(string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | propertyName |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
A property was dirty if it had been changed and the changes were committed.
Events
View SourcePropertyChanged
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
| Type | Description |
|---|---|
| System.ComponentModel.PropertyChangedEventHandler |