private async Task SignInAsync(ApplicationUser user, bool isPersistent) { //Limpiadmos la cookie de sesion AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = isPersistent }, await IdendityUserPropertiesService.GenerateUserIdentityAsync(user, UserManager)); }
public void ConfigureAuth(IAppBuilder app) { app.CreatePerOwinContext(CustomIdentityContext.Create); app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login"), Provider = new CookieAuthenticationProvider { OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, ApplicationUser>( validateInterval: TimeSpan.FromMinutes(30), regenerateIdentity: (manager, user) => IdendityUserPropertiesService.GenerateUserIdentityAsync(user, manager)) } }); // Para agregar cookies de servicios externos tipo Google, twitter, etc //app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); }