Skip to content

Commit

Permalink
Merge pull request #80 from pedroMF1996/Identity
Browse files Browse the repository at this point in the history
Identity
  • Loading branch information
pedroMF1996 authored Oct 25, 2023
2 parents f2552b2 + b4d026e commit 4a5027c
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ public async Task<IActionResult> Registrar(RegisterUserViewModel model)
if (result.Succeeded)
{
var clienteResult = await RegistrarCliente(model);

if (!clienteResult.ValidationResult.IsValid)
{
await _userManager.DeleteAsync(user);
return CustomResponse(clienteResult.ValidationResult);
}

await _userManager.AddClaimAsync(user, new Claim("catalogo", "Ler"));

return CustomResponse(await GerarJWT(model.Email));
}

Expand Down Expand Up @@ -124,6 +126,7 @@ private async Task<ClaimsIdentity> ObterClaimsUsuarioAsync(IdentityUser user, IL
claims.Add(new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()));
claims.Add(new Claim(JwtRegisteredClaimNames.Nbf, ToUnixEpochDate(DateTime.UtcNow).ToString())); //quando vai espirar
claims.Add(new Claim(JwtRegisteredClaimNames.Iat, ToUnixEpochDate(DateTime.UtcNow).ToString(), ClaimValueTypes.Integer64)); //quando foi emitido
claims.Add(new Claim("catalogo", "Ler"));

foreach (var role in roles)
{
Expand Down

0 comments on commit 4a5027c

Please sign in to comment.