public IResult Generate(LoginDto login) { //TODO: //CONSULTAR USUARIO PARA AUTENTICAR CredentialEntity credentialEntity = new CredentialEntity(login.User); if (credentialEntity.Invalid || !_consumerRepository.Exists(long.Parse(login.User))) { return(new ValidateResult(credentialEntity.Notifications, false, "Probleamas ao obter acesso")); } SymmetricSecurityKey symmetricSecurityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["Jwt:Key"])); SigningCredentials signingCredentials = new SigningCredentials(symmetricSecurityKey, SecurityAlgorithms.HmacSha256); List <Claim> claims = new List <Claim> { new Claim(nameof(login.User), login.User) }; JwtSecurityToken jwtSecurityToken = new JwtSecurityToken( issuer: _configuration["Jwt:Issuer"], audience: _configuration["Jwt:Audience"], expires: DateTime.Now.AddMinutes(120), claims: claims, signingCredentials: signingCredentials); string token = new JwtSecurityTokenHandler().WriteToken(jwtSecurityToken); return(new ValidateResult(token, true, "Acesso permitido")); }