Merge branch 'Test_IRC_Net8' of https://gitea.frp.extimaging.com/XCKJ/irc-netcore-api into Test_IRC_Net8
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
+15
@@ -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 UserDisable(Guid userId) => $"UserDisable:{userId}";
|
||||
|
||||
public static string UserRoleDisable(Guid userRoleId) => $"UserRoleDisable:{userRoleId}";
|
||||
|
||||
/// <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 _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)
|
||||
{
|
||||
find.IsUserRoleDisabled = role.IsUserRoleDisabled;
|
||||
|
||||
await _fusionCache.SetAsync(CacheKeys.UserRoleDisable(find.Id), find.IsUserRoleDisabled, TimeSpan.FromHours(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -690,6 +695,9 @@ namespace IRaCIS.Core.Application.Service
|
||||
if (find != null)
|
||||
{
|
||||
find.IsUserRoleDisabled = role.IsUserRoleDisabled;
|
||||
|
||||
|
||||
await _fusionCache.SetAsync(CacheKeys.UserRoleDisable(find.Id), find.IsUserRoleDisabled, TimeSpan.FromHours(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1155,6 +1163,9 @@ namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
var jwt = _tokenService.GetToken(userTokenInfo);
|
||||
|
||||
|
||||
await _fusionCache.SetAsync(CacheKeys.UserToken(userTokenInfo.IdentityUserId), jwt, TimeSpan.FromDays(7));
|
||||
|
||||
return jwt;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user