Exemple #1
0
        private AuthenticationResponseDto GetAuthenticationResponse(string email, string refreshToken)
        {
            if (!string.IsNullOrEmpty(refreshToken))
            {
                var claims = new[]
                {
                    new Claim(ClaimTypes.Email, email)
                };
                var credentials = new SigningCredentials(securityConfiguration.GetEncodingKey(), securityConfiguration.SigningAlgorithm);

                var jwtToken = new JwtSecurityToken(
                    securityConfiguration.Issuer,
                    securityConfiguration.Audience,
                    claims,
                    expires: DateTime.Now.AddMinutes(securityConfiguration.AccessExpiration),
                    signingCredentials: credentials
                    );
                string accessToken = new JwtSecurityTokenHandler().WriteToken(jwtToken);
                return(new AuthenticationResponseDto(accessToken, refreshToken));
            }

            return(null);
        }