public async Task<ActionResult> AddRandomClaims(AddRandomClaims model) { var userId = ClaimsPrincipal.Current.Identity.GetUserId(); var user = await userManager.FindByIdAsync(userId); for (int i = 0; i < model.NumberOfClaims; i++) { var claim = GenerateRandomString(model.LengthOfClaimName); var claimValue = GenerateRandomString(model.LengthOfValue); await userManager.AddClaimAsync(userId, new Claim(claim, claimValue)); } await userManager.SignInAsync(AuthenticationManager, user, true); return RedirectToAction("Index"); }
public async Task <ActionResult> AddRandomClaims(AddRandomClaims model) { var userId = ClaimsPrincipal.Current.Identity.GetUserId(); var user = await userManager.FindByIdAsync(userId); for (int i = 0; i < model.NumberOfClaims; i++) { var claim = GenerateRandomString(model.LengthOfClaimName); var claimValue = GenerateRandomString(model.LengthOfValue); await userManager.AddClaimAsync(userId, new Claim(claim, claimValue)); } await userManager.SignInAsync(AuthenticationManager, user, true); return(RedirectToAction("Index")); }