Class User
Represents a user object with extended properties and behavior.
Implements
Inherited Members
Namespace: DataWeb.Identity
Assembly: DataWeb.Core.dll
Syntax
public class User : IUser
Remarks
The user state is populated by calling InitAsync(IIdentity). Before initialization, the user is treated as anonymous.
Constructors
User(IUserSettingStore)
Represents a user object with extended properties and behavior.
Declaration
public User(IUserSettingStore userSettingStore)
Parameters
| Type | Name | Description |
|---|---|---|
| IUserSettingStore | userSettingStore | The user setting repository. |
Remarks
The user state is populated by calling InitAsync(IIdentity). Before initialization, the user is treated as anonymous.
Properties
Claims
Gets or sets the list of claims for the user.
Declaration
public IEnumerable<Claim> Claims { get; set; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<Claim> |
Culture
Gets or sets the culture code for the user (e.g. en-US).
Defaults to en-US when the claim is not present.
Declaration
public string Culture { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Gets or sets the email address of the user.
Declaration
public string Email { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
IdMaster
Gets or sets the master identifier of the user across the system. Defaults to VoidIdMaster for anonymous users.
Declaration
public string IdMaster { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Identity
Gets or sets the ClaimsIdentity for the user.
null when the user is not authenticated or the identity is not a ClaimsIdentity.
Declaration
public ClaimsIdentity Identity { get; set; }
Property Value
| Type | Description |
|---|---|
| ClaimsIdentity |
IsAuthenticated
Gets or sets a value indicating whether the user is authenticated.
Declaration
public bool IsAuthenticated { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
IsDataWeb
Gets or sets a value indicating whether the user has DataWeb administration privileges.
Declaration
public bool IsDataWeb { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
IsEditable
Gets or sets a value indicating whether the user is editable.
Declaration
public bool IsEditable { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
PublishMode
Gets or sets the publish mode of the user.
Declaration
public PublishMode PublishMode { get; set; }
Property Value
| Type | Description |
|---|---|
| PublishMode |
Roles
Gets or sets the list of roles for the user.
Declaration
public List<string> Roles { get; set; }
Property Value
| Type | Description |
|---|---|
| List<string> |
UserName
Gets or sets the user name.
Declaration
public string UserName { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
InitAsync(IIdentity)
Initializes the user properties from the provided IIdentity.
If identity is not authenticated, all properties are reset to their anonymous defaults.
For DataWeb users, the PublishMode is loaded from the user setting store.
Declaration
public Task InitAsync(IIdentity identity)
Parameters
| Type | Name | Description |
|---|---|---|
| IIdentity | identity | The identity to initialize the user from. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |
IsInRole(string)
Determines whether the user belongs to the specified role. The comparison is case-insensitive.
Declaration
public bool IsInRole(string roleName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | roleName | The name of the role to check. |
Returns
| Type | Description |
|---|---|
| bool |
|