失败的次数和限制时间增加到配置文件里面
parent
398a804b41
commit
7a6e4d5f2c
|
@ -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"
|
||||
}
|
||||
|
||||
}
|
|
@ -19,7 +19,11 @@
|
|||
|
||||
"OpenTrialRelationDelete": true,
|
||||
|
||||
"OpenLoginLimit": false
|
||||
"OpenLoginLimit": false,
|
||||
|
||||
"LoginMaxFailCount": 3,
|
||||
|
||||
"LoginFailLockMinutes":1
|
||||
},
|
||||
|
||||
"SystemEmailSendConfig": {
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
|
||||
"OpenSignDocumentBeforeWork": true,
|
||||
|
||||
"OpenLoginLimit": true
|
||||
"OpenLoginLimit": true,
|
||||
"LoginMaxFailCount": 3,
|
||||
|
||||
"LoginFailLockMinutes": 1
|
||||
},
|
||||
//"SystemEmailSendConfig": {
|
||||
// "Port": 465,
|
||||
|
|
|
@ -16,7 +16,10 @@
|
|||
|
||||
"OpenSignDocumentBeforeWork": true,
|
||||
|
||||
"OpenLoginLimit": true
|
||||
"OpenLoginLimit": true,
|
||||
"LoginMaxFailCount": 3,
|
||||
|
||||
"LoginFailLockMinutes": 1
|
||||
|
||||
},
|
||||
"SystemEmailSendConfig": {
|
||||
|
|
|
@ -19,7 +19,11 @@
|
|||
|
||||
"OpenTrialRelationDelete": true,
|
||||
|
||||
"OpenLoginLimit": false
|
||||
"OpenLoginLimit": false,
|
||||
|
||||
"LoginMaxFailCount": 3,
|
||||
|
||||
"LoginFailLockMinutes": 1
|
||||
},
|
||||
|
||||
"SystemEmailSendConfig": {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue