/// <inheritdoc/> public override Task <IdentityResult> DeleteAsync(TUser user, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); user.ThrowIfNull(nameof(user)); return(UsersTable.DeleteAsync(user.Id)); }
/// <inheritdoc/> protected override async Task <TUser> FindUserAsync(TKey userId, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); var user = await UsersTable.FindByIdAsync(userId); return(user); }
/// <inheritdoc/> public override async Task <TUser> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); var user = await UsersTable.FindByNameAsync(normalizedUserName); return(user); }
/// <inheritdoc/> public override Task <IdentityResult> UpdateAsync(TUser user, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); user.ThrowIfNull(nameof(user)); user.ConcurrencyStamp = Guid.NewGuid().ToString(); return(UsersTable.UpdateAsync(user, UserClaims, UserLogins, UserTokens)); }
/// <inheritdoc/> public override async Task <IList <TUser> > GetUsersForClaimAsync(Claim claim, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); claim.ThrowIfNull(nameof(claim)); var users = await UsersTable.GetUsersForClaimAsync(claim); return(users.ToList()); }
/// <inheritdoc/> public override async Task <TUser> FindByIdAsync(string userId, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); var id = ConvertIdFromString(userId); var user = await UsersTable.FindByIdAsync(id); return(user); }
public UserStore(IDatabaseConnectionFactory databaseConnectionFactory) { _usersTable = new UsersTable(databaseConnectionFactory); _usersRolesTable = new UserRolesTable(databaseConnectionFactory); _rolesTable = new RolesTable(databaseConnectionFactory); _usersClaimsTable = new UserClaimsTable(databaseConnectionFactory); _usersLoginsTable = new UserLoginsTable(databaseConnectionFactory); _userTokensTable = new UserTokensTable(databaseConnectionFactory); }
/// <inheritdoc/> public override async Task <IdentityResult> DeleteAsync(TUser user, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); user.ThrowIfNull(nameof(user)); var deleted = await UsersTable.DeleteAsync(user.Id); return(deleted ? IdentityResult.Success : IdentityResult.Failed(new IdentityError { Code = string.Empty, Description = $"User '{user.UserName}' could not be deleted." })); }
/// <inheritdoc/> public override async Task <IdentityResult> UpdateAsync(TUser user, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); user.ThrowIfNull(nameof(user)); user.ConcurrencyStamp = Guid.NewGuid().ToString(); var updated = await UsersTable.UpdateAsync(user, UserClaims, UserRoles, UserLogins, UserTokens); return(updated ? IdentityResult.Success : IdentityResult.Failed(new IdentityError { Code = string.Empty, Description = $"User '{user.UserName}' could not be deleted." })); }
/// <inheritdoc/> public override async Task <IList <TUser> > GetUsersInRoleAsync(string normalizedRoleName, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); if (string.IsNullOrEmpty(normalizedRoleName)) { throw new ArgumentNullException(nameof(normalizedRoleName)); } var role = await FindRoleAsync(normalizedRoleName, cancellationToken); var users = new List <TUser>(); if (role != null) { users = (await UsersTable.GetUsersInRoleAsync(normalizedRoleName)).ToList(); } return(users); }