Plugins.Add(new AuthFeature(() => new CustomUserSession(),
new IAuthProvider[]
{
new BasicAuthProvider(), //Sign-in with Basic Auth
new CredentialsAuthProvider(),
}));
the follow code is works fine. the after UserSession.UserName = 123
container.Register<IRedisClientsManager>(
c => new PooledRedisClientManager($"password@{RedisServer}:port"));
container.Register(c =>
c.Resolve<IRedisClientsManager>().GetCacheClient());
then the UserSession.UserName = “456”. not changed . I found it the UserAuth used the Redis cache.
How to update the UserSession to Reids?
sorry. In your source code, It Has AuthSession, UserSession, and the above base.Request.GetSession() , I have some confused with these Session, is there any document can find the difference?
namespace ServiceStack.Mvc
{
public abstract class ServiceStackController<T> : ServiceStackController where T : IAuthSession
{
protected ServiceStackController();
public IAuthSession AuthSession { get; }
protected T UserSession { get; }
}
}
public abstract class ServiceStackController<T> : ServiceStackController
where T : IAuthSession
{
protected T UserSession
{
get { return SessionAs<T>(); }
}
public IAuthSession AuthSession
{
get { return UserSession; }
}
}
It’s the same instance casted into the IAuthSession interface.