示例#1
0
 private AuthenticationProperties GetAuthenticationProperties(TicketEntity signUpTicket)
 {
     return new AuthenticationProperties
     {
         ExpiresUtc = DateTime.UtcNow.AddMinutes(3600),
         IsPersistent = true,
         AllowRefresh = true
     };
 }
示例#2
0
        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();
		}
示例#4
0
 public async Task SignInAsync(TicketEntity signUpTicket)
 {
     await HttpContextAccessor.HttpContext.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, GetClaimsPrincipal(signUpTicket), GetAuthenticationProperties(signUpTicket));
 }
示例#5
0
 public async Task<AuthenticationTicket> GetTicketAsync(TicketEntity signUpTicket)
 {
     return await Task.Run(() =>
     {
         return new AuthenticationTicket(GetClaimsPrincipal(signUpTicket), GetAuthenticationProperties(signUpTicket), CookieAuthenticationDefaults.AuthenticationScheme);
     });
 }