Class SqliteUserStore<TUser>
- Namespace
- Hi.SqliteUtils
- Assembly
- HiNc.dll
SQLite-based user store for ASP.NET Core Identity.
public class SqliteUserStore<TUser> : IUserStore<TUser>, IUserPasswordStore<TUser>, IUserRoleStore<TUser>, IUserEmailStore<TUser>, IUserPhoneNumberStore<TUser>, IUserTwoFactorStore<TUser>, IUserLockoutStore<TUser>, IUserSecurityStampStore<TUser>, IQueryableUserStore<TUser>, IUserStore<TUser>, IDisposable where TUser : SqliteIdentityUser, new()
Type Parameters
TUserThe type of user.
- Inheritance
-
SqliteUserStore<TUser>
- Implements
-
IUserStore<TUser>IUserPasswordStore<TUser>IUserRoleStore<TUser>IUserEmailStore<TUser>IUserPhoneNumberStore<TUser>IUserTwoFactorStore<TUser>IUserLockoutStore<TUser>IUserSecurityStampStore<TUser>IQueryableUserStore<TUser>IUserStore<TUser>
- Inherited Members
- Extension Methods
Constructors
SqliteUserStore(SqliteIdentityStorage)
public SqliteUserStore(SqliteIdentityStorage storage)
Parameters
storageSqliteIdentityStorage
Properties
Users
Returns an IQueryable<T> collection of users.
public IQueryable<TUser> Users { get; }
Property Value
- IQueryable<TUser>
An IQueryable<T> collection of users.
Methods
AddToRoleAsync(TUser, string, CancellationToken)
Add the specified user to the named role.
public Task AddToRoleAsync(TUser user, string roleName, CancellationToken cancellationToken)
Parameters
userTUserThe user to add to the named role.
roleNamestringThe name of the role to add the user to.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
CreateAsync(TUser, CancellationToken)
Creates the specified user in the user store.
public Task<IdentityResult> CreateAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user to create.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IdentityResult>
The Task that represents the asynchronous operation, containing the IdentityResult of the creation operation.
DeleteAsync(TUser, CancellationToken)
Deletes the specified user from the user store.
public Task<IdentityResult> DeleteAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user to delete.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IdentityResult>
The Task that represents the asynchronous operation, containing the IdentityResult of the delete operation.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
FindByEmailAsync(string, CancellationToken)
Gets the user, if any, associated with the specified, normalized email address.
public Task<TUser> FindByEmailAsync(string normalizedEmail, CancellationToken cancellationToken)
Parameters
normalizedEmailstringThe normalized email address to return the user for.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TUser>
The task object containing the results of the asynchronous lookup operation, the user if any associated with the specified normalized email address.
FindByIdAsync(string, CancellationToken)
Finds and returns a user, if any, who has the specified userId.
public Task<TUser> FindByIdAsync(string userId, CancellationToken cancellationToken)
Parameters
userIdstringThe user ID to search for.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TUser>
The Task that represents the asynchronous operation, containing the user matching the specified
userIdif it exists.
FindByNameAsync(string, CancellationToken)
Finds and returns a user, if any, who has the specified normalized user name.
public Task<TUser> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken)
Parameters
normalizedUserNamestringThe normalized user name to search for.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<TUser>
The Task that represents the asynchronous operation, containing the user matching the specified
normalizedUserNameif it exists.
GetAccessFailedCountAsync(TUser, CancellationToken)
Retrieves the current failed access count for the specified user.
public Task<int> GetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose failed access count should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
GetEmailAsync(TUser, CancellationToken)
Gets the email address for the specified user.
public Task<string> GetEmailAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose email should be returned.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
The task object containing the results of the asynchronous operation, the email address for the specified
user.
GetEmailConfirmedAsync(TUser, CancellationToken)
Gets a flag indicating whether the email address for the specified user has been verified, true if the email address is verified otherwise
false.
public Task<bool> GetEmailConfirmedAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose email confirmation status should be returned.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<bool>
The task object containing the results of the asynchronous operation, a flag indicating whether the email address for the specified
userhas been confirmed or not.
GetLockoutEnabledAsync(TUser, CancellationToken)
Retrieves a flag indicating whether user lockout can enabled for the specified user.
public Task<bool> GetLockoutEnabledAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose ability to be locked out should be returned.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<bool>
The Task that represents the asynchronous operation, true if a user can be locked out, otherwise false.
GetLockoutEndDateAsync(TUser, CancellationToken)
Gets the last DateTimeOffset a user's last lockout expired, if any. Any time in the past should be indicates a user is not locked out.
public Task<DateTimeOffset?> GetLockoutEndDateAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose lockout date should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<DateTimeOffset?>
A Task<TResult> that represents the result of the asynchronous query, a DateTimeOffset containing the last time a user's lockout expired, if any.
GetNormalizedEmailAsync(TUser, CancellationToken)
Returns the normalized email for the specified user.
public Task<string> GetNormalizedEmailAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose email address to retrieve.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
The task object containing the results of the asynchronous lookup operation, the normalized email address if any associated with the specified user.
GetNormalizedUserNameAsync(TUser, CancellationToken)
Gets the normalized user name for the specified user.
public Task<string> GetNormalizedUserNameAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose normalized name should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
The Task that represents the asynchronous operation, containing the normalized user name for the specified
user.
GetPasswordHashAsync(TUser, CancellationToken)
Gets the password hash for the specified user.
public Task<string> GetPasswordHashAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose password hash to retrieve.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
The Task that represents the asynchronous operation, returning the password hash for the specified
user.
GetPhoneNumberAsync(TUser, CancellationToken)
Gets the telephone number, if any, for the specified user.
public Task<string> GetPhoneNumberAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose telephone number should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
The Task that represents the asynchronous operation, containing the user's telephone number, if any.
GetPhoneNumberConfirmedAsync(TUser, CancellationToken)
Gets a flag indicating whether the specified user's telephone number has been confirmed.
public Task<bool> GetPhoneNumberConfirmedAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user to return a flag for, indicating whether their telephone number is confirmed.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<bool>
The Task that represents the asynchronous operation, returning true if the specified
userhas a confirmed telephone number otherwise false.
GetRolesAsync(TUser, CancellationToken)
Gets a list of role names the specified user belongs to.
public Task<IList<string>> GetRolesAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose role names to retrieve.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IList<string>>
The Task that represents the asynchronous operation, containing a list of role names.
GetSecurityStampAsync(TUser, CancellationToken)
Get the security stamp for the specified user.
public Task<string> GetSecurityStampAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose security stamp should be set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
The Task that represents the asynchronous operation, containing the security stamp for the specified
user.
GetTwoFactorEnabledAsync(TUser, CancellationToken)
Returns a flag indicating whether the specified user has two factor authentication enabled or not,
as an asynchronous operation.
public Task<bool> GetTwoFactorEnabledAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose two factor authentication enabled status should be set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<bool>
The Task that represents the asynchronous operation, containing a flag indicating whether the specified
userhas two factor authentication enabled or not.
GetUserIdAsync(TUser, CancellationToken)
Gets the user identifier for the specified user.
public Task<string> GetUserIdAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose identifier should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
The Task that represents the asynchronous operation, containing the identifier for the specified
user.
GetUserNameAsync(TUser, CancellationToken)
Gets the user name for the specified user.
public Task<string> GetUserNameAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose name should be retrieved.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<string>
The Task that represents the asynchronous operation, containing the name for the specified
user.
GetUsersInRoleAsync(string, CancellationToken)
Returns a list of Users who are members of the named role.
public Task<IList<TUser>> GetUsersInRoleAsync(string roleName, CancellationToken cancellationToken)
Parameters
roleNamestringThe name of the role whose membership should be returned.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IList<TUser>>
The Task that represents the asynchronous operation, containing a list of users who are in the named role.
HasPasswordAsync(TUser, CancellationToken)
Gets a flag indicating whether the specified user has a password.
public Task<bool> HasPasswordAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user to return a flag for, indicating whether they have a password or not.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<bool>
The Task that represents the asynchronous operation, returning true if the specified
userhas a password otherwise false.
IncrementAccessFailedCountAsync(TUser, CancellationToken)
Records that a failed access has occurred, incrementing the failed access count.
public Task<int> IncrementAccessFailedCountAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose cancellation count should be incremented.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<int>
The Task that represents the asynchronous operation, containing the incremented failed access count.
IsInRoleAsync(TUser, string, CancellationToken)
Returns a flag indicating whether the specified user is a member of the given named role.
public Task<bool> IsInRoleAsync(TUser user, string roleName, CancellationToken cancellationToken)
Parameters
userTUserThe user whose role membership should be checked.
roleNamestringThe name of the role to be checked.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<bool>
The Task that represents the asynchronous operation, containing a flag indicating whether the specified
useris a member of the named role.
RemoveFromRoleAsync(TUser, string, CancellationToken)
Remove the specified user from the named role.
public Task RemoveFromRoleAsync(TUser user, string roleName, CancellationToken cancellationToken)
Parameters
userTUserThe user to remove the named role from.
roleNamestringThe name of the role to remove.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
ResetAccessFailedCountAsync(TUser, CancellationToken)
Resets a user's failed access count.
public Task ResetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user whose failed access count should be reset.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
Remarks
This is typically called after the account is successfully accessed.
SetEmailAsync(TUser, string, CancellationToken)
Sets the email address for a user.
public Task SetEmailAsync(TUser user, string email, CancellationToken cancellationToken)
Parameters
userTUserThe user whose email should be set.
emailstringThe email to set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task
The task object representing the asynchronous operation.
SetEmailConfirmedAsync(TUser, bool, CancellationToken)
Sets the flag indicating whether the specified user's email address has been confirmed or not.
public Task SetEmailConfirmedAsync(TUser user, bool confirmed, CancellationToken cancellationToken)
Parameters
userTUserThe user whose email confirmation status should be set.
confirmedboolA flag indicating if the email address has been confirmed, true if the address is confirmed otherwise false.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task
The task object representing the asynchronous operation.
SetLockoutEnabledAsync(TUser, bool, CancellationToken)
Set the flag indicating if the specified user can be locked out.
public Task SetLockoutEnabledAsync(TUser user, bool enabled, CancellationToken cancellationToken)
Parameters
userTUserThe user whose ability to be locked out should be set.
enabledboolA flag indicating if lock out can be enabled for the specified
user.cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetLockoutEndDateAsync(TUser, DateTimeOffset?, CancellationToken)
Locks out a user until the specified end date has passed. Setting a end date in the past immediately unlocks a user.
public Task SetLockoutEndDateAsync(TUser user, DateTimeOffset? lockoutEnd, CancellationToken cancellationToken)
Parameters
userTUserThe user whose lockout date should be set.
lockoutEndDateTimeOffset?The DateTimeOffset after which the
user's lockout should end.cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetNormalizedEmailAsync(TUser, string, CancellationToken)
Sets the normalized email for the specified user.
public Task SetNormalizedEmailAsync(TUser user, string normalizedEmail, CancellationToken cancellationToken)
Parameters
userTUserThe user whose email address to set.
normalizedEmailstringThe normalized email to set for the specified
user.cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task
The task object representing the asynchronous operation.
SetNormalizedUserNameAsync(TUser, string, CancellationToken)
Sets the given normalized name for the specified user.
public Task SetNormalizedUserNameAsync(TUser user, string normalizedName, CancellationToken cancellationToken)
Parameters
userTUserThe user whose name should be set.
normalizedNamestringThe normalized name to set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetPasswordHashAsync(TUser, string, CancellationToken)
Sets the password hash for the specified user.
public Task SetPasswordHashAsync(TUser user, string passwordHash, CancellationToken cancellationToken)
Parameters
userTUserThe user whose password hash to set.
passwordHashstringThe password hash to set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetPhoneNumberAsync(TUser, string, CancellationToken)
Sets the telephone number for the specified user.
public Task SetPhoneNumberAsync(TUser user, string phoneNumber, CancellationToken cancellationToken)
Parameters
userTUserThe user whose telephone number should be set.
phoneNumberstringThe telephone number to set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetPhoneNumberConfirmedAsync(TUser, bool, CancellationToken)
Sets a flag indicating if the specified user's phone number has been confirmed.
public Task SetPhoneNumberConfirmedAsync(TUser user, bool confirmed, CancellationToken cancellationToken)
Parameters
userTUserThe user whose telephone number confirmation status should be set.
confirmedboolA flag indicating whether the user's telephone number has been confirmed.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetSecurityStampAsync(TUser, string, CancellationToken)
Sets the provided security stamp for the specified user.
public Task SetSecurityStampAsync(TUser user, string stamp, CancellationToken cancellationToken)
Parameters
userTUserThe user whose security stamp should be set.
stampstringThe security stamp to set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetTwoFactorEnabledAsync(TUser, bool, CancellationToken)
Sets a flag indicating whether the specified user has two factor authentication enabled or not,
as an asynchronous operation.
public Task SetTwoFactorEnabledAsync(TUser user, bool enabled, CancellationToken cancellationToken)
Parameters
userTUserThe user whose two factor authentication enabled status should be set.
enabledboolA flag indicating whether the specified
userhas two factor authentication enabled.cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
SetUserNameAsync(TUser, string, CancellationToken)
Sets the given userName for the specified user.
public Task SetUserNameAsync(TUser user, string userName, CancellationToken cancellationToken)
Parameters
userTUserThe user whose name should be set.
userNamestringThe user name to set.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
UpdateAsync(TUser, CancellationToken)
Updates the specified user in the user store.
public Task<IdentityResult> UpdateAsync(TUser user, CancellationToken cancellationToken)
Parameters
userTUserThe user to update.
cancellationTokenCancellationTokenThe CancellationToken used to propagate notifications that the operation should be canceled.
Returns
- Task<IdentityResult>
The Task that represents the asynchronous operation, containing the IdentityResult of the update operation.