How to keep user login in to system and logout only after user clicks on logout button?

后端 未结 8 1452
傲寒
傲寒 2021-02-13 10:26

I am using custom implementation of microsoft asp.net identity because i have custom tables that is why i have given custom implementation of all my methods IUserStore a

8条回答
  •  梦毁少年i
    2021-02-13 10:46

    Have you tried

     ExpireTimeSpan = TimeSpan.FromDays(7);
    

    so this would make your code:

    public partial class Startup
        {
            public void ConfigureAuth(IAppBuilder app)
            {
                app.CreatePerOwinContext(ApplicationDbContext.Create);
                app.CreatePerOwinContext(ApplicationUserManager.Create);
                app.CreatePerOwinContext(ApplicationSignInManager.Create);
                app.UseCookieAuthentication(new CookieAuthenticationOptions
                {
                    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                    LoginPath = new PathString("/Account/Login"),
                    Provider = new CookieAuthenticationProvider
                    {
                        OnValidateIdentity = SecurityStampValidator.OnValidateIdentity(
                            validateInterval: TimeSpan.FromMinutes(30),
                            regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                    }
                });
    
                ExpireTimeSpan = TimeSpan.FromDays(7);
                app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
                app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));
            }
        }
    

提交回复
热议问题