public async Task <AuthenticatedAccountResponse> AuthenticateAsync(Account account)
        {
            string accessToken  = _accessTokenGenerator.GenerateToken(account);
            string refreshToken = _refreshTokenGenerator.GenerateToken();

            RefreshToken refreshTokenDTO = new RefreshToken()
            {
                Token     = refreshToken,
                AccountId = account.Id
            };
            await _refreshTokenRepository.CreateAsync(refreshTokenDTO);

            return(new AuthenticatedAccountResponse(accessToken, refreshToken));
        }
Ejemplo n.º 2
0
        public async Task <AuthenticatedUserResponse> Authenticate(User user)
        {
            string accessToken  = _accessTokenGenerator.GenerateToken(user);
            string refreshToken = _refreshTokenGenerator.GenerateToken();

            RefreshToken refreshTokenDTO = new RefreshToken()
            {
                Token  = refreshToken,
                UserId = user.Id
            };
            await _refreshTokenRepository.Create(refreshTokenDTO);

            return(new AuthenticatedUserResponse()
            {
                AccessToken = accessToken,
                RefreshToken = refreshToken
            });
        }