修改角色禁用
parent
4cdf94d29c
commit
2509e26aae
|
@ -153,7 +153,6 @@ namespace IRaCIS.Api.Controllers
|
||||||
// 验证阅片休息时间
|
// 验证阅片休息时间
|
||||||
await readingImageTaskService.ResetReadingRestTime(userId);
|
await readingImageTaskService.ResetReadingRestTime(userId);
|
||||||
|
|
||||||
await _fusionCache.SetAsync(CacheKeys.UserToken(userId), loginReturn.JWTStr, TimeSpan.FromDays(7));
|
|
||||||
|
|
||||||
await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(userId), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(_verifyConfig.CurrentValue.AutoLoginOutMinutes));
|
await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(userId), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(_verifyConfig.CurrentValue.AutoLoginOutMinutes));
|
||||||
|
|
||||||
|
@ -279,7 +278,7 @@ namespace IRaCIS.Api.Controllers
|
||||||
// 验证阅片休息时间
|
// 验证阅片休息时间
|
||||||
await readingImageTaskService.ResetReadingRestTime(returnModel.Data.BasicInfo.IdentityUserId);
|
await readingImageTaskService.ResetReadingRestTime(returnModel.Data.BasicInfo.IdentityUserId);
|
||||||
|
|
||||||
await _fusionCache.SetAsync(CacheKeys.UserToken(userId), returnModel.Data.JWTStr, TimeSpan.FromDays(7));
|
|
||||||
|
|
||||||
await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(userId), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(_verifyConfig.CurrentValue.AutoLoginOutMinutes));
|
await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(userId), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(_verifyConfig.CurrentValue.AutoLoginOutMinutes));
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
|
|
||||||
"OpenTrialRelationDelete": true,
|
"OpenTrialRelationDelete": true,
|
||||||
|
|
||||||
"OpenLoginLimit": false,
|
"OpenLoginLimit": true,
|
||||||
|
|
||||||
"LoginMaxFailCount": 5,
|
"LoginMaxFailCount": 5,
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,21 @@ public class LimitUserRequestAuthorization(
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//用户或者角色禁用,那么操作的人退出
|
||||||
|
|
||||||
|
var isDisable = await _fusionCache.GetOrDefaultAsync<bool>(CacheKeys.UserDisable(_userInfo.IdentityUserId),false);
|
||||||
|
|
||||||
|
var isRoleDisable = await _fusionCache.GetOrDefaultAsync<bool>(CacheKeys.UserRoleDisable(_userInfo.UserRoleId),false);
|
||||||
|
|
||||||
|
if (isDisable == true || isRoleDisable == true)
|
||||||
|
{
|
||||||
|
context.HttpContext.Response.ContentType = "application/json";
|
||||||
|
context.HttpContext.Response.StatusCode = StatusCodes.Status403Forbidden;
|
||||||
|
// 用户或者角色被禁用。
|
||||||
|
|
||||||
|
context.Result = new JsonResult(ResponseOutput.NotOk(_localizer["LimitUser_AccountOrRoleDisable"], ApiResponseCodeEnum.AutoLoginOut));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,11 @@ public static class CacheKeys
|
||||||
//超时没请求接口自动退出
|
//超时没请求接口自动退出
|
||||||
public static string UserAutoLoginOut(Guid userId) => $"UserAutoLoginOut:{userId}";
|
public static string UserAutoLoginOut(Guid userId) => $"UserAutoLoginOut:{userId}";
|
||||||
|
|
||||||
|
|
||||||
|
public static string UserDisable(Guid userId) => $"UserDisable:{userId}";
|
||||||
|
|
||||||
|
public static string UserRoleDisable(Guid userRoleId) => $"UserRoleDisable:{userRoleId}";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户登录错误 限制登录
|
/// 用户登录错误 限制登录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -615,6 +615,9 @@ namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = model.Id, OptType = model.Status == UserStateEnum.Enable ? UserOptType.AccountEnable : UserOptType.AccountLocked }, true);
|
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = model.Id, OptType = model.Status == UserStateEnum.Enable ? UserOptType.AccountEnable : UserOptType.AccountLocked }, true);
|
||||||
|
|
||||||
|
|
||||||
|
await _fusionCache.SetAsync(CacheKeys.UserDisable(user.Id), model.Status == UserStateEnum.Disable, TimeSpan.FromHours(1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -636,6 +639,8 @@ namespace IRaCIS.Core.Application.Service
|
||||||
if (find != null)
|
if (find != null)
|
||||||
{
|
{
|
||||||
find.IsUserRoleDisabled = role.IsUserRoleDisabled;
|
find.IsUserRoleDisabled = role.IsUserRoleDisabled;
|
||||||
|
|
||||||
|
await _fusionCache.SetAsync(CacheKeys.UserRoleDisable(find.Id), find.IsUserRoleDisabled, TimeSpan.FromHours(1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -690,6 +695,9 @@ namespace IRaCIS.Core.Application.Service
|
||||||
if (find != null)
|
if (find != null)
|
||||||
{
|
{
|
||||||
find.IsUserRoleDisabled = role.IsUserRoleDisabled;
|
find.IsUserRoleDisabled = role.IsUserRoleDisabled;
|
||||||
|
|
||||||
|
|
||||||
|
await _fusionCache.SetAsync(CacheKeys.UserRoleDisable(find.Id), find.IsUserRoleDisabled, TimeSpan.FromHours(1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1149,6 +1157,9 @@ namespace IRaCIS.Core.Application.Service
|
||||||
{
|
{
|
||||||
var jwt = _tokenService.GetToken(userTokenInfo);
|
var jwt = _tokenService.GetToken(userTokenInfo);
|
||||||
|
|
||||||
|
|
||||||
|
await _fusionCache.SetAsync(CacheKeys.UserToken(userTokenInfo.IdentityUserId), jwt, TimeSpan.FromDays(7));
|
||||||
|
|
||||||
return jwt;
|
return jwt;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue