Table of Contents

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

TUser

The type of user.

Inheritance
SqliteUserStore<TUser>
Implements
IUserStore<TUser>
IUserStore<TUser>
Inherited Members
Extension Methods

Constructors

SqliteUserStore(SqliteIdentityStorage)

public SqliteUserStore(SqliteIdentityStorage storage)

Parameters

storage SqliteIdentityStorage

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

user TUser

The user to add to the named role.

roleName string

The name of the role to add the user to.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

CreateAsync(TUser, CancellationToken)

Creates the specified user in the user store.

public Task<IdentityResult> CreateAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user to create.

cancellationToken CancellationToken

The 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

user TUser

The user to delete.

cancellationToken CancellationToken

The 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

normalizedEmail string

The normalized email address to return the user for.

cancellationToken CancellationToken

The 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

userId string

The user ID to search for.

cancellationToken CancellationToken

The 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 userId if 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

normalizedUserName string

The normalized user name to search for.

cancellationToken CancellationToken

The 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 normalizedUserName if it exists.

GetAccessFailedCountAsync(TUser, CancellationToken)

Retrieves the current failed access count for the specified user.

public Task<int> GetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user whose failed access count should be retrieved.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task<int>

The Task that represents the asynchronous operation, containing the failed access count.

GetEmailAsync(TUser, CancellationToken)

Gets the email address for the specified user.

public Task<string> GetEmailAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user whose email should be returned.

cancellationToken CancellationToken

The 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

user TUser

The user whose email confirmation status should be returned.

cancellationToken CancellationToken

The 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 user has 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

user TUser

The user whose ability to be locked out should be returned.

cancellationToken CancellationToken

The 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

user TUser

The user whose lockout date should be retrieved.

cancellationToken CancellationToken

The 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

user TUser

The user whose email address to retrieve.

cancellationToken CancellationToken

The 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

user TUser

The user whose normalized name should be retrieved.

cancellationToken CancellationToken

The 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

user TUser

The user whose password hash to retrieve.

cancellationToken CancellationToken

The 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

user TUser

The user whose telephone number should be retrieved.

cancellationToken CancellationToken

The 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

user TUser

The user to return a flag for, indicating whether their telephone number is confirmed.

cancellationToken CancellationToken

The 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 user has 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

user TUser

The user whose role names to retrieve.

cancellationToken CancellationToken

The 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

user TUser

The user whose security stamp should be set.

cancellationToken CancellationToken

The 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

user TUser

The user whose two factor authentication enabled status should be set.

cancellationToken CancellationToken

The 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 user has 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

user TUser

The user whose identifier should be retrieved.

cancellationToken CancellationToken

The 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

user TUser

The user whose name should be retrieved.

cancellationToken CancellationToken

The 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

roleName string

The name of the role whose membership should be returned.

cancellationToken CancellationToken

The 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

user TUser

The user to return a flag for, indicating whether they have a password or not.

cancellationToken CancellationToken

The 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 user has 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

user TUser

The user whose cancellation count should be incremented.

cancellationToken CancellationToken

The 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

user TUser

The user whose role membership should be checked.

roleName string

The name of the role to be checked.

cancellationToken CancellationToken

The 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 user is 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

user TUser

The user to remove the named role from.

roleName string

The name of the role to remove.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

ResetAccessFailedCountAsync(TUser, CancellationToken)

Resets a user's failed access count.

public Task ResetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user whose failed access count should be reset.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

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

user TUser

The user whose email should be set.

email string

The email to set.

cancellationToken CancellationToken

The 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

user TUser

The user whose email confirmation status should be set.

confirmed bool

A flag indicating if the email address has been confirmed, true if the address is confirmed otherwise false.

cancellationToken CancellationToken

The 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

user TUser

The user whose ability to be locked out should be set.

enabled bool

A flag indicating if lock out can be enabled for the specified user.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

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

user TUser

The user whose lockout date should be set.

lockoutEnd DateTimeOffset?

The DateTimeOffset after which the user's lockout should end.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

SetNormalizedEmailAsync(TUser, string, CancellationToken)

Sets the normalized email for the specified user.

public Task SetNormalizedEmailAsync(TUser user, string normalizedEmail, CancellationToken cancellationToken)

Parameters

user TUser

The user whose email address to set.

normalizedEmail string

The normalized email to set for the specified user.

cancellationToken CancellationToken

The 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

user TUser

The user whose name should be set.

normalizedName string

The normalized name to set.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

SetPasswordHashAsync(TUser, string, CancellationToken)

Sets the password hash for the specified user.

public Task SetPasswordHashAsync(TUser user, string passwordHash, CancellationToken cancellationToken)

Parameters

user TUser

The user whose password hash to set.

passwordHash string

The password hash to set.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

SetPhoneNumberAsync(TUser, string, CancellationToken)

Sets the telephone number for the specified user.

public Task SetPhoneNumberAsync(TUser user, string phoneNumber, CancellationToken cancellationToken)

Parameters

user TUser

The user whose telephone number should be set.

phoneNumber string

The telephone number to set.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

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

user TUser

The user whose telephone number confirmation status should be set.

confirmed bool

A flag indicating whether the user's telephone number has been confirmed.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

SetSecurityStampAsync(TUser, string, CancellationToken)

Sets the provided security stamp for the specified user.

public Task SetSecurityStampAsync(TUser user, string stamp, CancellationToken cancellationToken)

Parameters

user TUser

The user whose security stamp should be set.

stamp string

The security stamp to set.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

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

user TUser

The user whose two factor authentication enabled status should be set.

enabled bool

A flag indicating whether the specified user has two factor authentication enabled.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

SetUserNameAsync(TUser, string, CancellationToken)

Sets the given userName for the specified user.

public Task SetUserNameAsync(TUser user, string userName, CancellationToken cancellationToken)

Parameters

user TUser

The user whose name should be set.

userName string

The user name to set.

cancellationToken CancellationToken

The CancellationToken used to propagate notifications that the operation should be canceled.

Returns

Task

The Task that represents the asynchronous operation.

UpdateAsync(TUser, CancellationToken)

Updates the specified user in the user store.

public Task<IdentityResult> UpdateAsync(TUser user, CancellationToken cancellationToken)

Parameters

user TUser

The user to update.

cancellationToken CancellationToken

The 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.