mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 17:53:25 +08:00
【优化】后台单点登录有效时间调整为最长24小时,并优化挤退策略。
This commit is contained in:
@@ -124,24 +124,14 @@ namespace CoreCms.Net.Auth
|
|||||||
if (string.IsNullOrEmpty(mJwt))
|
if (string.IsNullOrEmpty(mJwt))
|
||||||
{
|
{
|
||||||
context.Response.Headers.Append("Token-Error-Token", "UserLoginStatusError");
|
context.Response.Headers.Append("Token-Error-Token", "UserLoginStatusError");
|
||||||
var jm = new AdminUiCallBack();
|
context.Token = "";
|
||||||
jm.code = 401;
|
|
||||||
jm.data = 401;
|
|
||||||
jm.msg = "Sorry, your login information could not be found.";
|
|
||||||
context.Response.WriteAsync(JsonConvert.SerializeObject(jm));
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mJwt != token)
|
if (mJwt != token)
|
||||||
{
|
{
|
||||||
context.Response.Headers.Append("Token-Error-Token", "The current user logged in elsewhere");
|
context.Response.Headers.Append("Token-Error-Token", "The current user logged in elsewhere");
|
||||||
var jm = new AdminUiCallBack();
|
context.Token = "";
|
||||||
jm.code = 401;
|
|
||||||
jm.data = 401;
|
|
||||||
jm.msg = "Sorry, your account has already been logged in elsewhere.";
|
|
||||||
context.Response.WriteAsync(JsonConvert.SerializeObject(jm));
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
|||||||
|
|
||||||
//缓存登录数据
|
//缓存登录数据
|
||||||
var cacheKey = $"LoginUser:{user.id}";
|
var cacheKey = $"LoginUser:{user.id}";
|
||||||
ManualDataCache.Instance.Set(cacheKey, auth.token);
|
ManualDataCache.Instance.Set(cacheKey, auth.token, 1440);
|
||||||
|
|
||||||
//插入登录日志
|
//插入登录日志
|
||||||
var log = new SysLoginRecord();
|
var log = new SysLoginRecord();
|
||||||
|
|||||||
Reference in New Issue
Block a user