Example #1
0
        SignIn(
            ApplicationUser 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 = user.GenerateUserIdentity(_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);
            }
        }
Example #2
0
 private void SignIn(ApplicationUser user, bool isPersistent)
 {
     AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
     AuthenticationManager.SignIn(new AuthenticationProperties()
     {
         IsPersistent = isPersistent
     }, user.GenerateUserIdentity(UserManager));
 }
Example #3
0
 GenerateUserIdentityAsync(this ApplicationUser user, ApplicationUserManager manager)
 {
     return(Task.FromResult(user.GenerateUserIdentity(manager)));
 }
        public void SignIn(
         ApplicationUser 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 = user.GenerateUserIdentity(_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);
             }
        }