public async Task <JWTTokenStatusResult> GenerateTokenAsync(AuthSignInModel model)
        {
            Boolean status = await VerifyUserAsync(model);

            if (!status)
            {
                return(new JWTTokenStatusResult()
                {
                    Token = null, IsAuthorized = false
                });
            }

            IEnumerable <Claim> claims = await GetUserClaimsAsync(model);

            JwtSecurityToken token = _tokenFactory.CreateToken(model.Email.ToString(), claims);

            return(new JWTTokenStatusResult()
            {
                Token = new JwtSecurityTokenHandler().WriteToken(token),
                IsAuthorized = true,
                Features = claims.Select(x => x.Value)
            });
        }
Ejemplo n.º 2
0
        public async Task <JWTTokenStatusResult> GenerateTokenAsync(AuthSignInModel model)
        {
            bool status = await VerifyUserAsync(model);

            if (!status)
            {
                return(new JWTTokenStatusResult()
                {
                    Token = null, IsAuthorized = false
                });
            }

            IEnumerable <Claim> claims = await GetUserClaimsAsync(model);

            JwtSecurityToken token = _tokenFactory.CreateToken(model.UserName.ToString(), claims);
            UserAuthInfo     info  = await GetUserInfoAsync(model.UserName);

            return(new JWTTokenStatusResult()
            {
                Token = new JwtSecurityTokenHandler().WriteToken(token),
                IsAuthorized = true,
                UserInfo = info,
            });
        }