public static async Task SignIn(AuthenticationManager authentication, string monsterName) { // Create claims var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, monsterName), new Claim(CookieMonsterSecurity.MonsterTypeClaim, MonsterTypes.Good), }, CookieMonsterSecurity.CookieMonsterAuthenticationSchema); var user = new ClaimsPrincipal(identity); await authentication.SignInAsync(CookieMonsterSecurity.CookieMonsterAuthenticationSchema, user); }
public static void SignIn(AuthenticationManager authenticationManager, User user) { var claims = new List<Claim> { new Claim(ClaimTypes.Email, user.EMail, ClaimValueTypes.String, Issuer), new Claim(ClaimTypes.UserData, user.Id.ToString(), ClaimValueTypes.Integer32, Issuer) }; var userIdentity = new ClaimsIdentity("Email"); userIdentity.AddClaims(claims); var userPrincipal = new ClaimsPrincipal(userIdentity); authenticationManager.SignInAsync(AuthenticationSchema, userPrincipal, new AuthenticationProperties { ExpiresUtc = DateTime.UtcNow.AddMinutes(20), IsPersistent = false, AllowRefresh = true }).Wait(); }