0
I made an authentication using Claims
with cookies
in the ASP.NET Core
.
In the Method below, the object by parameter brings the login information and inside it has a list called PerfisDeAcesso
. How do I assign this list to ClaimTypes.Role
? I ask because he only accepts one element of the kind string
and my list has more than one element (like string
).
No one was accepted foreach
within.
private async Task<IActionResult> SignInAsync(Usuario usuario)
{
var claims = new List<Claim>
{
new Claim(ClaimTypes.NameIdentifier, usuario.CodUsuario),
new Claim(ClaimTypes.Name, usuario.Login),
new Claim(ClaimTypes.Role, /* lista com os perfis de acesso */)
};
var identity = new ClaimsIdentity(claims, "login");
var principal = new ClaimsPrincipal(identity);
await HttpContext.SignInAsync(principal);
return RedirectToAction("Index", "Home");
}