public object Login([FromServices] JwtConfiguration tokenConfigurations, [FromBody] LoginViewModel model) { if (!ModelState.IsValid) { return(GetErros()); } string token = string.Empty; var user = UserRepositoryMock.GetUser(model.Username, model.Password); if (user != null) { token = new JwtTokenBuilder() .AddSecurityKey(JwtSecurityKey.Create(tokenConfigurations.JwtKey)) .AddSubject(user.Name) .AddIssuer(tokenConfigurations.Issuer) .AddAudience(tokenConfigurations.Audience) .AddNameId(user.Username) .AddExpiryDays(tokenConfigurations.Days) //Adicionado um claim com os perfis de uso. .AddClaimsPermission(user.Permissions) .Build(); return(new { token }); } else { return(BadRequest( new { message = "Usuário ou senha inválidos!" } )); } }