失败的次数和限制时间增加到配置文件里面

Uat_Study
hang 2023-06-29 14:33:16 +08:00
parent 398a804b41
commit 7a6e4d5f2c
7 changed files with 59 additions and 7 deletions

View File

@ -0,0 +1,31 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"ConnectionStrings": {
"RemoteNew": "Server=123.56.94.154,1433\\MSSQLSERVER;Database=CenterImage_Test;User ID=sa;Password=dev123456DEV;TrustServerCertificate=true"
},
"BasicSystemConfig": {
"OpenUserComplexPassword": false,
"OpenSignDocumentBeforeWork": false,
"OpenTrialRelationDelete": true,
"OpenLoginLimit": false
},
"SystemEmailSendConfig": {
"Port": 465,
"Host": "smtp.qiye.aliyun.com",
"FromEmail": "test@extimaging.com",
"FromName": "Test_IRC",
"AuthorizationCode": "SHzyyl2021"
}
}

View File

@ -19,7 +19,11 @@
"OpenTrialRelationDelete": true,
"OpenLoginLimit": false
"OpenLoginLimit": false,
"LoginMaxFailCount": 3,
"LoginFailLockMinutes":1
},
"SystemEmailSendConfig": {

View File

@ -17,7 +17,10 @@
"OpenSignDocumentBeforeWork": true,
"OpenLoginLimit": true
"OpenLoginLimit": true,
"LoginMaxFailCount": 3,
"LoginFailLockMinutes": 1
},
//"SystemEmailSendConfig": {
// "Port": 465,

View File

@ -16,7 +16,10 @@
"OpenSignDocumentBeforeWork": true,
"OpenLoginLimit": true
"OpenLoginLimit": true,
"LoginMaxFailCount": 3,
"LoginFailLockMinutes": 1
},
"SystemEmailSendConfig": {

View File

@ -19,7 +19,11 @@
"OpenTrialRelationDelete": true,
"OpenLoginLimit": false
"OpenLoginLimit": false,
"LoginMaxFailCount": 3,
"LoginFailLockMinutes": 1
},
"SystemEmailSendConfig": {

View File

@ -26,6 +26,8 @@ namespace IRaCIS.Application.Services
private readonly IMemoryCache _cache;
private readonly IOptionsMonitor<ServiceVerifyConfigOption> _verifyConfig;
public UserService(IRepository<User> userRepository,
IMailVerificationService mailVerificationService,
@ -617,8 +619,8 @@ namespace IRaCIS.Application.Services
{
const string cachePrefix = "login-failures:";
const int maxFailures = 3;
const int lockoutMinutes = 1;
int maxFailures = _verifyConfig.CurrentValue.LoginMaxFailCount;
int lockoutMinutes = _verifyConfig.CurrentValue.LoginFailLockMinutes;
// 生成缓存键
string cacheKey = $"{cachePrefix}{userName}";
@ -637,7 +639,7 @@ namespace IRaCIS.Application.Services
if (failCount >= maxFailures)
{
throw new BusinessValidationFailedException($"密码连续错误3次,当前账号已被限制登录,请等待 {lockoutMinutes} 分钟后再试。");
throw new BusinessValidationFailedException($"密码连续错误{maxFailures}次,当前账号已被限制登录,请等待 {lockoutMinutes} 分钟后再试。");
}
var userLoginReturnModel = new LoginReturnDTO();

View File

@ -16,6 +16,11 @@ namespace IRaCIS.Core.Domain.Share
public bool OpenTrialRelationDelete { get; set; }
public bool OpenLoginLimit { get; set; }
public int LoginMaxFailCount { get; set; }
public int LoginFailLockMinutes { get; set; }
}
public class SystemEmailSendConfig