public async Task <Token> AuthenticationByPassword(String login, String password, CancellationToken cancellationToken) { var user = await _userGetter.Get(login, cancellationToken); if (user == null) { throw new UnauthorizedException(); } if (!user.IsActive) { throw new UnconfirmedException(); } if (!await _passwordHasher.VerifyHashedPassword(user.Password, password, cancellationToken)) { throw new UnauthorizedException(); } var refreshToken = await _refreshTokenStore.Add(user.Id); var accessToken = await _accessTokenFactory.Create(user, cancellationToken); return(new Token( accessToken: accessToken.Value, expiresIn: accessToken.ExpiresIn, refreshToken: refreshToken)); }
public ActionResult AddUsers(string id) { var addUserModel = new AddUsersModel() { VaultId = id, FreeUsers = _userGetter.Get().ToList(), }; return(PartialView(addUserModel)); }
public async Task <Token> AuthenticationByRefreshToken(string refreshToken, CancellationToken cancellationToken) { var newRefreshToken = await _refreshTokenStore.Reissue(refreshToken, cancellationToken); if (newRefreshToken == null) { throw new UnauthorizedException(); } var user = await _userRepository.Get(newRefreshToken.UserId, cancellationToken); var accessToken = await _accessTokenFactory.Create(user, cancellationToken); return(new Token(accessToken.Value, accessToken.ExpiresIn, newRefreshToken.Value)); }