重置密码,清理密码错误限制
This commit is contained in:
@@ -287,6 +287,10 @@ namespace IRaCIS.Core.Application.Service
|
||||
IsFirstAdd = true
|
||||
});
|
||||
|
||||
var userName = _userRepository.Where(t => t.Id == userId).Select(t => t.UserName).FirstOrDefault();
|
||||
|
||||
await _fusionCache.RemoveAsync(CacheKeys.UserLoginError(userName));
|
||||
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = _userInfo.Id, OptUserId = userId, OptType = UserOptType.ResetPassword }, true);
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
@@ -692,12 +696,11 @@ namespace IRaCIS.Core.Application.Service
|
||||
public async Task<IResponseOutput<LoginReturnDTO>> Login(string userName, string password)
|
||||
{
|
||||
|
||||
const string cachePrefix = "login-failures:";
|
||||
int maxFailures = _verifyConfig.CurrentValue.LoginMaxFailCount;
|
||||
int lockoutMinutes = _verifyConfig.CurrentValue.LoginFailLockMinutes;
|
||||
|
||||
// 生成缓存键
|
||||
string cacheKey = $"{cachePrefix}{userName}";
|
||||
string cacheKey = CacheKeys.UserLoginError(userName);
|
||||
|
||||
// 从缓存中获取登录失败次数
|
||||
int? failCount = await _fusionCache.GetOrDefaultAsync<int?>(cacheKey);
|
||||
|
||||
Reference in New Issue
Block a user