Example #1
0
        private async Task <AuthResult> GeneraAuthResultAsync(ApplicationUser user)
        {
            var newToken        = _jwtManager.GenerateTokenForUser(user);
            var newRefreshToken = await _jwtManager.GenerateRefreshTokenForJwtTokenAsync(user, newToken);

            if (newToken == null || newRefreshToken == null)
            {
                return(AuthResult.CreateWithSingleError("Couldn't create token for the user."));
            }

            return(new AuthResult
            {
                Success = true,
                Token = _jwtManager.SecurityTokenToString(newToken),
                RefreshToken = newRefreshToken.Token
            });
        }