【优化】后台单点登录有效时间调整为最长24小时,并优化挤退策略。

This commit is contained in:
大灰灰
2024-08-26 14:51:34 +08:00
parent 032149cbb9
commit c2446b01c5
2 changed files with 3 additions and 13 deletions

View File

@@ -124,24 +124,14 @@ namespace CoreCms.Net.Auth
if (string.IsNullOrEmpty(mJwt))
{
context.Response.Headers.Append("Token-Error-Token", "UserLoginStatusError");
var jm = new AdminUiCallBack();
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;
context.Token = "";
}
else
{
if (mJwt != token)
{
context.Response.Headers.Append("Token-Error-Token", "The current user logged in elsewhere");
var jm = new AdminUiCallBack();
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;
context.Token = "";
}
}
}

View File

@@ -141,7 +141,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
//缓存登录数据
var cacheKey = $"LoginUser:{user.id}";
ManualDataCache.Instance.Set(cacheKey, auth.token);
ManualDataCache.Instance.Set(cacheKey, auth.token, 1440);
//插入登录日志
var log = new SysLoginRecord();