private async Task SignInAsync(ApplicationUser user, bool isPersistent) { var clientKey = Request.Browser.Type; await UserManager.SignInClientAsync(user, clientKey); // Zerando contador de logins errados. await UserManager.ResetAccessFailedCountAsync(user.Id); // Coletando Claims externos (se houver) ClaimsIdentity ext = await AuthenticationManager.GetExternalIdentityAsync(DefaultAuthenticationTypes.ExternalCookie); AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie, DefaultAuthenticationTypes.TwoFactorCookie, DefaultAuthenticationTypes.ApplicationCookie); AuthenticationManager.SignIn ( new AuthenticationProperties { IsPersistent = isPersistent }, // Criação da instancia do Identity e atribuição dos Claims await user.GenerateUserIdentityAsync(UserManager, ext) ); }
private async Task SignInAsync(ApplicationUser user, bool isPersistent) { var clientKey = Request.Browser.Type; await UserManager.SignInClientAsync(user, clientKey); AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie, DefaultAuthenticationTypes.TwoFactorCookie); AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = isPersistent }, await user.GenerateUserIdentityAsync(UserManager)); }