2015-08-25 20 views

回答

0

你可以驗證時間間隔設置爲0,該數據庫將用於cookie驗證檢查每次:

app.UseCookieAuthentication(new CookieAuthenticationOptions 
    { 
     AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, 
     LoginPath = new PathString("/Account/Login"), 
     Provider = new CookieAuthenticationProvider 
     { 
      // Enables the application to validate the security stamp when the user logs in. 
      // This is a security feature which is used when you change a password or add an external login to your account. 
      OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
       validateInterval: TimeSpan.FromSeconds(0), 
       regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)) 
     } 
    }); 

並且,如果在,改變用戶登錄他的SecurityStamp。這會導致每個現有的Cookie無效:

UserManager.UpdateSecurityStamp(userId);