Ejemplo n.º 1
0
 private async Task SignInAsync(user_backend_Iuser user, bool isPersistent)
 {
     AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie, DefaultAuthenticationTypes.TwoFactorCookie);
     AuthenticationManager.SignIn(new AuthenticationProperties {
         IsPersistent = isPersistent
     }, await user.GenerateUserIdentityAsync(UserManager));
 }
Ejemplo n.º 2
0
        private async Task <SignInStatus> SignInOrTwoFactor(user_backend_Iuser user, bool isPersistent)
        {
            //if (await UserManager.GetTwoFactorEnabledAsync(user.Id) &&
            //    !await AuthenticationManager.TwoFactorBrowserRememberedAsync(user.Id))
            //{
            //    var identity = new ClaimsIdentity(DefaultAuthenticationTypes.TwoFactorCookie);
            //    identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id));
            //    AuthenticationManager.SignIn(identity);
            //    return SignInStatus.RequiresTwoFactorAuthentication;
            //}
            await SignInAsync(user, isPersistent, false);

            return(SignInStatus.Success);
        }
Ejemplo n.º 3
0
        public async Task SignInAsync(user_backend_Iuser user, bool isPersistent, bool rememberBrowser)
        {
            // Clear any partial cookies from external or two factor partial sign ins
            AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie, DefaultAuthenticationTypes.TwoFactorCookie);
            var userIdentity = await user.GenerateUserIdentityAsync(UserManager);

            if (rememberBrowser)
            {
                var rememberBrowserIdentity = AuthenticationManager.CreateTwoFactorRememberBrowserIdentity(user.Id);
                AuthenticationManager.SignIn(new AuthenticationProperties {
                    IsPersistent = isPersistent
                }, userIdentity, rememberBrowserIdentity);
            }
            else
            {
                AuthenticationManager.SignIn(new AuthenticationProperties {
                    IsPersistent = isPersistent
                }, userIdentity);
            }
        }