ASP.NET 5 Identity 3 users get signed out after some time

后端 未结 2 1528
长情又很酷
长情又很酷 2021-01-21 12:39

I\'m, using RC1 bits and external (Google) authentication, no Identity.EntityFramework.

During login, I set \'Remember me\' flag.

Logged-in user survives browser

2条回答
  •  有刺的猬
    2021-01-21 13:21

    Thank you very much for the previous answers, I worked with this problem today and I resolve with this:

    1.- Custom UserStore.cs:

    public class UserStore : IUserStore,                                                                                              
        IUserPasswordStore,                                                                                                           
        IUserEmailStore,                                                                                                              
        IUserRoleStore,                                                                                                               
        IUserSecurityStampStore                                                                                                       
    {  
        //omitted...
    
        public Task SetSecurityStampAsync(User user, string stamp, CancellationToken cancellationToken = default(CancellationToken))
        {
            user.SecurityStamp = stamp;
            return Task.FromResult(0);
        }
    
        public Task GetSecurityStampAsync(User user, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (user.SecurityStamp == null) {
                return Task.FromResult("AspNet.Identity.SecurityStamp");
            }
            return Task.FromResult(user.SecurityStamp);
        }
    }
    

    2.- In User.cs And DB Table User add SecurityStamp as string.

    For TEST change default 30m to 1m in Startup.cs:

    services.Configure(options => {        
        options.ValidationInterval = TimeSpan.FromMinutes(1);                  
    });
    

提交回复
热议问题