Interface IUserService
Represents a service for managing users, including creating, updating, and deleting users, as well as managing user roles, logins, settings, and sending emails for password reset and email confirmation.
Namespace: DataWeb.Identity
Assembly: DataWeb.Core.dll
Syntax
public interface IUserService
Properties
AppSettings
Gets the application settings.
Declaration
ConfigurationAppSettings AppSettings { get; }
Property Value
Type | Description |
---|---|
ConfigurationAppSettings |
Methods
AddUserLoginAsync(string, string, string, CancellationToken)
Adds a login to a user.
Declaration
Task AddUserLoginAsync(string userIdMaster, string providerKey, string loginProvider, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userIdMaster | The user's IdMaster. |
string | providerKey | The provider key. |
string | loginProvider | The login provider. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous operation. |
CreateUserAsync(AppIdentityUser, CancellationToken)
Creates a new user.
Declaration
Task<UserService.EditResult> CreateUserAsync(AppIdentityUser user, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
AppIdentityUser | user | The user to create. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<UserService.EditResult> | The edit result. |
DeleteUserAsync(AppIdentityUser, CancellationToken)
Deletes a user.
Declaration
Task DeleteUserAsync(AppIdentityUser user, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
AppIdentityUser | user | The user to delete. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | The task. |
EmailExistsAsync(string, CancellationToken)
Determines whether the specified email address is available for use.
Declaration
Task<bool> EmailExistsAsync(string email, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | The email address to check. |
|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<bool> | A task representing the asynchronous operation, returning true if the email address is available, and false otherwise. |
GetAllUserSettingsAsync(string, string, CancellationToken)
Gets all user settings for a user and navigation path.
Declaration
Task<IEnumerable<UserSetting>> GetAllUserSettingsAsync(string userIdMaster, string navigationPath = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userIdMaster | The user's IdMaster. |
string | navigationPath | The navigation path (optional). |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<IEnumerable<UserSetting>> | A task that represents the asynchronous operation. The task result contains an enumerable collection of UserSetting objects. |
GetRolesAsync(CancellationToken)
Gets all roles.
Declaration
Task<IEnumerable<AppIdentityRole>> GetRolesAsync(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<IEnumerable<AppIdentityRole>> | A task that represents the asynchronous operation. The task result contains an enumerable collection of AppIdentityRole objects. |
GetUserByEmailASync(string, PublishMode?, CancellationToken)
Gets a user by their email address.
Declaration
Task<AppIdentityUser> GetUserByEmailASync(string email, PublishMode? publishMode = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | The email address. |
|
PublishMode? | publishMode | The publish mode to filter by (optional). |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<AppIdentityUser> | The user with the specified email address, or null if the user was not found. |
GetUserByIdMasterAsync(string, PublishMode?, CancellationToken)
Gets a user by their IdMaster.
Declaration
Task<AppIdentityUser> GetUserByIdMasterAsync(string userIdMaster, PublishMode? publishMode = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userIdMaster | The user IdMaster. |
PublishMode? | publishMode | The publish mode to filter by (optional). |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<AppIdentityUser> | The user with the specified IdMaster, or null if the user was not found. |
GetUserByUserNameAsync(string, PublishMode?, CancellationToken)
Gets a user by their user name.
Declaration
Task<AppIdentityUser> GetUserByUserNameAsync(string userName, PublishMode? publishMode = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userName | The user name. |
PublishMode? | publishMode | The publish mode to filter by (optional). |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<AppIdentityUser> | The user with the specified user name, or null if the user was not found. |
GetUserLoginAsync(string, string, CancellationToken)
Gets a user's login by provider key and login provider.
Declaration
Task<UserLogin> GetUserLoginAsync(string providerKey, string loginProvider, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | providerKey | The provider key. |
string | loginProvider | The login provider. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<UserLogin> | A task that represents the asynchronous operation. The task result contains a UserLogin object, or null if the login was not found. |
GetUserLoginsAsync(string, CancellationToken)
Gets the logins for a user.
Declaration
Task<IEnumerable<UserLogin>> GetUserLoginsAsync(string userIdMaster, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userIdMaster | The user's IdMaster. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<IEnumerable<UserLogin>> | A task that represents the asynchronous operation. The task result contains an enumerable collection of UserLogin objects. |
GetUserRolesAsync(string, CancellationToken)
Gets the roles for a user.
Declaration
Task<string[]> GetUserRolesAsync(string userName, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userName | The user name. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<string[]> | A task that represents the asynchronous operation. The task result contains an array of strings representing the user's roles. |
GetUserSettingAsync(string, string, string, CancellationToken)
Gets the value of the specified user setting for the user with the given Id.
Declaration
Task<string> GetUserSettingAsync(string userIdMaster, string name, string navigationPath = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userIdMaster | The Id of the user to get the setting for. |
string | name | The name of the setting to get. |
string | navigationPath | The navigation path of the setting to get. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<string> | The value of the specified user setting. |
GetUserValueByEmailAsync(string, string, CancellationToken)
Gets the value of the specified user property by the user's email address.
Declaration
Task<object> GetUserValueByEmailAsync(string email, string name, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | The user's email address. |
|
string | name | The name of the property to get. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<object> | A task representing the asynchronous operation, returning the value of the specified property. |
GetUserValueByIdMasterAsync(string, string, CancellationToken)
Gets the value of the specified user property by the user's IdMaster.
Declaration
Task<object> GetUserValueByIdMasterAsync(string IdMaster, string name, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | IdMaster | The user's IdMaster. |
string | name | The name of the property to get. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<object> | A task representing the asynchronous operation, returning the value of the specified property. |
GetUserValueByUserNameAsync(string, string, CancellationToken)
Gets the value of the specified user property by the user's user name.
Declaration
Task<object> GetUserValueByUserNameAsync(string userName, string name, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userName | The user's user name. |
string | name | The name of the property to get. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<object> | A task representing the asynchronous operation, returning the value of the specified property. |
GetValidationError(string, string)
Gets a ValidationError object with the specified code and message.
Declaration
ValidationError GetValidationError(string code, string message)
Parameters
Type | Name | Description |
---|---|---|
string | code | The error code. |
string | message | The error message. |
Returns
Type | Description |
---|---|
ValidationError | A ValidationError object with the specified code and message. |
InitIdentityUser(string, string)
Initializes a new AppIdentityUser with the specified user name and email.
Declaration
AppIdentityUser InitIdentityUser(string userName, string email)
Parameters
Type | Name | Description |
---|---|---|
string | userName | The user name. |
string | The email. |
Returns
Type | Description |
---|---|
AppIdentityUser | The initialized user. |
IsEmailAvailableAsync(string, string, CancellationToken)
Checks if an email address is available.
Declaration
Task<bool> IsEmailAvailableAsync(string email, string userIdMaster, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | The email address to check. |
|
string | userIdMaster | The user's Id (if available). |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<bool> | A task that represents the asynchronous operation. The task result contains a boolean indicating whether the email address is available. |
IsUserInRoleAsync(string, string, CancellationToken)
Determines whether the specified user is in the specified role.
Declaration
Task<bool> IsUserInRoleAsync(string userName, string roleName, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userName | The name of the user. |
string | roleName | The name of the role. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<bool> | A task representing the asynchronous operation, returning true if the user is in the specified role, and false otherwise. |
IsUserNameAvailableAsync(string, string, CancellationToken)
Checks if a user name is available.
Declaration
Task<bool> IsUserNameAvailableAsync(string userName, string userIdMaster, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userName | The user name to check. |
string | userIdMaster | The user's Id (if available). |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<bool> | A task that represents the asynchronous operation. The task result contains a boolean indicating whether the user name is available. |
RemoveAllUserSettingsAsync(string, CancellationToken)
Removes all user settings for the user with the given Id.
Declaration
Task RemoveAllUserSettingsAsync(string userIdMaster, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userIdMaster | The Id of the user to remove all settings for. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
RemoveUserLoginAsync(string, string, string, CancellationToken)
Removes a login from a user.
Declaration
Task RemoveUserLoginAsync(string userIdMaster, string providerKey, string loginProvider, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userIdMaster | The user's IdMaster. |
string | providerKey | The provider key. |
string | loginProvider | The login provider. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous operation. |
RemoveUserSettingAsync(string, string, string, CancellationToken)
Removes the specified user setting for the user with the given Id.
Declaration
Task RemoveUserSettingAsync(string userIdMaster, string name, string navigationPath = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userIdMaster | The Id of the user to remove the setting for. |
string | name | The name of the setting to remove. |
string | navigationPath | The navigation path of the setting to remove. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
SendConfirmEmailAsync(AppIdentityUser, string, CancellationToken)
Sends an email confirmation email to a user.
Declaration
Task SendConfirmEmailAsync(AppIdentityUser identityUser, string emailConfirmUrl, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
AppIdentityUser | identityUser | The user. |
string | emailConfirmUrl | The email confirmation URL. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | The task. |
SendPasswordRemindEmailAsync(AppIdentityUser, string, CancellationToken)
Sends a password reminder email to the specified user.
Declaration
Task SendPasswordRemindEmailAsync(AppIdentityUser identityUser, string resetPasswordUrl, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
AppIdentityUser | identityUser | The user to send the email to. |
string | resetPasswordUrl | The URL to reset the password. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous operation. |
SendPasswordResetEmailAsync(AppIdentityUser, CancellationToken)
Sends a password reset email to the specified user.
Declaration
Task SendPasswordResetEmailAsync(AppIdentityUser identityUser, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
AppIdentityUser | identityUser | The user to send the email to. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous operation. |
SetIdentityClaims(ClaimsIdentity, AppIdentityUser)
Sets the claims for a user's identity.
Declaration
void SetIdentityClaims(ClaimsIdentity identity, AppIdentityUser user)
Parameters
Type | Name | Description |
---|---|---|
ClaimsIdentity | identity | The claims identity. |
AppIdentityUser | user | The user. |
SetStatusMessage(string)
Sets the status message for the current user.
Declaration
StatusMessage SetStatusMessage(string messageType)
Parameters
Type | Name | Description |
---|---|---|
string | messageType | The type of message to set. |
Returns
Type | Description |
---|---|
StatusMessage | A status message indicating success or failure. |
SetUserSettingAsync(string, string, string, string, CancellationToken)
Sets the value of the specified user setting for the user with the given Id.
Declaration
Task SetUserSettingAsync(string userIdMaster, string name, string value, string navigationPath = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | userIdMaster | The Id of the user to set the setting for. |
string | name | The name of the setting to set. |
string | value | The value to set the setting to. |
string | navigationPath | The navigation path of the setting to set. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
UpdateUserAsync(AppIdentityUser, CancellationToken)
Updates an existing user.
Declaration
Task<UserService.EditResult> UpdateUserAsync(AppIdentityUser user, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
AppIdentityUser | user | The user to update. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<UserService.EditResult> | The edit result. |
UserHasPasswordAsync(string, CancellationToken)
Determines whether the specified user has a password.
Declaration
Task<bool> UserHasPasswordAsync(string IdMaster, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | IdMaster | The user's IdMaster. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<bool> | A task representing the asynchronous operation, returning true if the user has a password, and false otherwise. |