Class User
Represents a backoffice user
Namespace: Umbraco.Cms.Core.Models.Membership
Assembly: Umbraco.Core.dll
Syntax
[DataContract(IsReference = true)]
public class User : EntityBase, IUser, IMembershipUser, IEntity, IDeepCloneable, IRememberBeingDirty, ICanBeDirty, IProfile
Constructors
View SourceUser(GlobalSettings)
Constructor for creating a new/empty user
Declaration
public User(GlobalSettings globalSettings)
Parameters
| Type | Name | Description |
|---|---|---|
| GlobalSettings | globalSettings | The global settings for default values. |
User(GlobalSettings, int, string?, string, string?, string?, string?, IEnumerable<IReadOnlyUserGroup>, int[], int[])
Constructor for creating a new User instance for an existing user
Declaration
public User(GlobalSettings globalSettings, int id, string? name, string email, string? username, string? rawPasswordValue, string? passwordConfig, IEnumerable<IReadOnlyUserGroup> userGroups, int[] startContentIds, int[] startMediaIds)
Parameters
| Type | Name | Description |
|---|---|---|
| GlobalSettings | globalSettings | The global settings for default values. |
| int | id | The unique identifier for the user. |
| string | name | The display name of the user. |
| string | The email address of the user. |
|
| string | username | The username for the user. |
| string | rawPasswordValue | The raw password value for the user. |
| string | passwordConfig | The password configuration for the user. |
| IEnumerable<IReadOnlyUserGroup> | userGroups | The user groups the user belongs to. |
| int[] | startContentIds | The starting content node identifiers. |
| int[] | startMediaIds | The starting media node identifiers. |
User(GlobalSettings, string?, string, string, string)
Constructor for creating a new/empty user
Declaration
public User(GlobalSettings globalSettings, string? name, string email, string username, string rawPasswordValue)
Parameters
| Type | Name | Description |
|---|---|---|
| GlobalSettings | globalSettings | The global settings for default values. |
| string | name | The display name of the user. |
| string | The email address of the user. |
|
| string | username | The username for the user. |
| string | rawPasswordValue | The raw password value for the user. |
Properties
View SourceAllowedSections
Gets the collection of section aliases that this user has access to.
Declaration
public IEnumerable<string> AllowedSections { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<string> |
Avatar
Will hold the media file system relative path of the users custom avatar if they uploaded one
Declaration
[DataMember]
public string? Avatar { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Comments
Gets or sets any comments associated with the membership user.
Declaration
[IgnoreDataMember]
public string? Comments { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Gets or sets the email address for the membership user.
Declaration
[DataMember]
public string Email { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
EmailConfirmedDate
Gets or sets the date and time when the email was confirmed.
Declaration
[DataMember]
public DateTime? EmailConfirmedDate { get; set; }
Property Value
| Type | Description |
|---|---|
| DateTime? |
FailedPasswordAttempts
Gets or sets the number of failed password attempts. This is the number of times the password was entered incorrectly upon login.
Declaration
[IgnoreDataMember]
public int FailedPasswordAttempts { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
Alias: umbracoMemberFailedPasswordAttempts Part of the standard properties collection.
Groups
Gets the groups that user is part of
Declaration
[DataMember]
public IEnumerable<IReadOnlyUserGroup> Groups { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<IReadOnlyUserGroup> |
InvitedDate
Gets or sets the date and time when the user was invited.
Declaration
[DataMember]
public DateTime? InvitedDate { get; set; }
Property Value
| Type | Description |
|---|---|
| DateTime? |
IsApproved
Gets or sets a value indicating whether the membership user is approved.
Declaration
[DataMember]
public bool IsApproved { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
IsLockedOut
Gets or sets a value indicating whether the membership user is locked out.
Declaration
[IgnoreDataMember]
public bool IsLockedOut { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Kind
The type of user.
Declaration
[DataMember]
public UserKind Kind { get; set; }
Property Value
| Type | Description |
|---|---|
| UserKind |
Language
Gets or sets the preferred language for the user's backoffice UI.
Declaration
[DataMember]
public string? Language { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
LastLockoutDate
Gets or sets the date and time when the user was last locked out.
Declaration
[IgnoreDataMember]
public DateTime? LastLockoutDate { get; set; }
Property Value
| Type | Description |
|---|---|
| DateTime? |
LastLoginDate
Gets or sets the date and time of the user's last login.
Declaration
[IgnoreDataMember]
public DateTime? LastLoginDate { get; set; }
Property Value
| Type | Description |
|---|---|
| DateTime? |
LastPasswordChangeDate
Gets or sets the date and time when the password was last changed.
Declaration
[IgnoreDataMember]
public DateTime? LastPasswordChangeDate { get; set; }
Property Value
| Type | Description |
|---|---|
| DateTime? |
Name
Gets or sets the display name of the user.
Declaration
[DataMember]
public string? Name { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
PasswordConfiguration
The user's specific password config (i.e. algorithm type, etc...)
Declaration
[IgnoreDataMember]
public string? PasswordConfiguration { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
ProfileData
Exposes the basic profile data
Declaration
public IProfile ProfileData { get; }
Property Value
| Type | Description |
|---|---|
| IProfile |
RawPasswordValue
Gets or sets the raw password value
Declaration
[IgnoreDataMember]
public string? RawPasswordValue { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
SecurityStamp
The security stamp used by ASP.Net identity
Declaration
[IgnoreDataMember]
public string? SecurityStamp { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
SessionTimeout
Gets or sets the session timeout.
Declaration
[DataMember]
public int SessionTimeout { get; set; }
Property Value
| Type | Description |
|---|---|
| int | The session timeout. |
StartContentIds
Gets or sets the start content id.
Declaration
[DataMember]
[DoNotClone]
public int[]? StartContentIds { get; set; }
Property Value
| Type | Description |
|---|---|
| int[] | The start content id. |
StartMediaIds
Gets or sets the start media id.
Declaration
[DataMember]
[DoNotClone]
public int[]? StartMediaIds { get; set; }
Property Value
| Type | Description |
|---|---|
| int[] | The start media id. |
UserState
Gets the current state of the user.
Declaration
public UserState UserState { get; }
Property Value
| Type | Description |
|---|---|
| UserState |
Username
Gets or sets the username for the membership user.
Declaration
[DataMember]
public string Username { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
View SourceAddGroup(IReadOnlyUserGroup)
Adds the user to the specified group.
Declaration
public void AddGroup(IReadOnlyUserGroup group)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyUserGroup | group | The group to add the user to. |
ClearGroups()
Removes the user from all groups.
Declaration
public void ClearGroups()
PerformDeepClone(object)
Used by inheritors to modify the DeepCloning logic
Declaration
protected override void PerformDeepClone(object clone)
Parameters
| Type | Name | Description |
|---|---|---|
| object | clone |
RemoveGroup(string)
Removes the user from the specified group.
Declaration
public void RemoveGroup(string group)
Parameters
| Type | Name | Description |
|---|---|---|
| string | group | The alias of the group to remove the user from. |