Exemplo n.º 1
0
 public async Task SignInAsync(BasicSignInContext context)
 {
     if (context.IsSignInRequired())
     {
         context.Principal = _options.Secret != null
             ? SignInUsingSecret(context)
             : await _authenticationService.SignInAsync(context.Username, context.Password, context.Scheme.Name);
     }
     else
     {
         var claims         = new[] { new Claim(ClaimTypes.Anonymous, "") };
         var claimsIdentity = new ClaimsIdentity(claims, context.Scheme.Name);
         context.Principal = new ClaimsPrincipal(claimsIdentity);
     }
 }
Exemplo n.º 2
0
        public async Task SignInAsync(BasicSignInContext context)
        {
            ClaimsPrincipal principal;

            if (context.IsSignInRequired())
            {
                principal = _options.Secret != null?SignInUsingSecret(context) : await _authenticationService.SignInAsync(context.Username, context.Password, context.Options.AuthenticationScheme);
            }
            else
            {
                var claims         = new[] { new Claim(ClaimTypes.Anonymous, "") };
                var claimsIdentity = new ClaimsIdentity(claims, context.Options.AuthenticationScheme);
                principal = new ClaimsPrincipal(claimsIdentity);
            }

            if (principal != null)
            {
                context.Ticket = new AuthenticationTicket(principal, new AuthenticationProperties(), context.Options.AuthenticationScheme);
            }

            context.HandleResponse();
        }