Ejemplo n.º 1
0
 /// <inheritdoc/>
 public override Task <IdentityResult> DeleteAsync(TUser user, CancellationToken cancellationToken)
 {
     cancellationToken.ThrowIfCancellationRequested();
     ThrowIfDisposed();
     user.ThrowIfNull(nameof(user));
     return(UsersTable.DeleteAsync(user.Id));
 }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        protected override async Task <TUser> FindUserAsync(TKey userId, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            var user = await UsersTable.FindByIdAsync(userId);

            return(user);
        }
Ejemplo n.º 3
0
        /// <inheritdoc/>
        public override async Task <TUser> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            ThrowIfDisposed();
            var user = await UsersTable.FindByNameAsync(normalizedUserName);

            return(user);
        }
Ejemplo n.º 4
0
 /// <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));
 }
Ejemplo n.º 5
0
        /// <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());
        }
Ejemplo n.º 6
0
        /// <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);
        }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
        /// <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."
            }));
        }
Ejemplo n.º 9
0
        /// <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."
            }));
        }
Ejemplo n.º 10
0
        /// <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);
        }