public static async Task ValidateAsync(CookieValidatePrincipalContext context) { var userPrincipal = context.Principal; ClaimsExtension.UpdateClaim(userPrincipal, ClaimTypes.Email, "*****@*****.**"); ClaimsExtension.UpdateClaim(userPrincipal, ClaimTypes.Name, "test"); ClaimsExtension.UpdateClaim(userPrincipal, "FullName", "test.test"); context.ShouldRenew = true; context.ReplacePrincipal(userPrincipal); var s = ClaimsExtension.GetClaimValue(userPrincipal, "FullName"); var r = ClaimsExtension.GetClaimValue(userPrincipal, ClaimTypes.Email); }
public async Task <IActionResult> Index() { var principal = HttpContext.User; ClaimsExtension.UpdateClaim(principal, ClaimTypes.Email, "*****@*****.**"); ClaimsExtension.UpdateClaim(principal, ClaimTypes.Name, "test"); ClaimsExtension.UpdateClaim(principal, "FullName", "test.test"); await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal); var s = ClaimsExtension.GetClaimValue(principal, "FullName"); var r = ClaimsExtension.GetClaimValue(principal, ClaimTypes.Email); return(View()); }