Пример #1
0
 internal string GenerateToken()
 {
     return(_tokenGenerator.GenerateToken(
                _authenConfig,
                _authenConfig.RefreshTokenSecret,
                _authenConfig.RefreshTokenExpirationMinutes));
 }
Пример #2
0
        internal string GenerateToken(User user)
        {
            List <Claim> _claims = new List <Claim>()
            {
                new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
                new Claim("id", user.Id.ToString()),
                new Claim("username", user.Username),
                new Claim("roleId", user.Role.Id.ToString()),
                new Claim("Name", user.Name ?? ""),
                new Claim("Email", user.Email ?? ""),
                new Claim(ClaimTypes.Role, user.Role.RoleName),
            };

            return(_tokenGenerator.GenerateToken(
                       _configuration,
                       _configuration.AccessTokenSecret,
                       _configuration.AccessTokenExpirationMinutes,
                       _claims
                       ));
        }