private AuthenticationProperties GetAuthenticationProperties(TicketEntity signUpTicket) { return new AuthenticationProperties { ExpiresUtc = DateTime.UtcNow.AddMinutes(3600), IsPersistent = true, AllowRefresh = true }; }
private ClaimsPrincipal GetClaimsPrincipal(TicketEntity signUpTicket) { ClaimsIdentity userIdentity = new ClaimsIdentity("SuperSecureLogin"); List<Claim> claims = new List<Claim> { new Claim(ClaimTypes.Country, signUpTicket.Culture, ApplicationSettings.Name), new Claim(ClaimTypes.Name, signUpTicket.Name, ClaimValueTypes.String, ApplicationSettings.Name), new Claim(ClaimTypes.NameIdentifier, signUpTicket.Key.ToString(), ClaimValueTypes.String, ApplicationSettings.Name) }; userIdentity.AddClaims(claims); return new ClaimsPrincipal(userIdentity); }
public async Task SignInAsync(TicketEntity signUpTicket) { if (signUpTicket != null && signUpTicket.Status == TicketStatus.Sucess) { IsAuthenticated = true; Culture = signUpTicket.Culture; UserKey = signUpTicket.Key; User = new ExecuteUser { Key = signUpTicket.Key, Name = signUpTicket.Name, Login = "******" }; return; } await SignOutAsync(); }
public async Task SignInAsync(TicketEntity signUpTicket) { await HttpContextAccessor.HttpContext.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, GetClaimsPrincipal(signUpTicket), GetAuthenticationProperties(signUpTicket)); }
public async Task<AuthenticationTicket> GetTicketAsync(TicketEntity signUpTicket) { return await Task.Run(() => { return new AuthenticationTicket(GetClaimsPrincipal(signUpTicket), GetAuthenticationProperties(signUpTicket), CookieAuthenticationDefaults.AuthenticationScheme); }); }