修改
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
7f28c984e1
commit
f55fa98dec
|
@ -39,7 +39,10 @@ namespace IRaCIS.Application.Contracts
|
||||||
|
|
||||||
public UserTypeEnum UserTypeEnum { get; set; }
|
public UserTypeEnum UserTypeEnum { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上一次修改密码的时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? LastChangePassWordTime { get; set; }
|
||||||
public bool IsTestUser { get; set; }
|
public bool IsTestUser { get; set; }
|
||||||
public bool IsAdmin { get; set; } = false;
|
public bool IsAdmin { get; set; } = false;
|
||||||
public string UserTypeShortName { get; set; } = string.Empty;
|
public string UserTypeShortName { get; set; } = string.Empty;
|
||||||
|
@ -55,6 +58,8 @@ namespace IRaCIS.Application.Contracts
|
||||||
public bool IsFirstAdd { get; set; }
|
public bool IsFirstAdd { get; set; }
|
||||||
public bool IsReviewer { get; set; } = false;
|
public bool IsReviewer { get; set; } = false;
|
||||||
|
|
||||||
|
public int LoginState { get; set; } = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MenuFuncTreeNodeView
|
public class MenuFuncTreeNodeView
|
||||||
|
|
|
@ -23,12 +23,13 @@ namespace IRaCIS.Application.Services
|
||||||
public class UserService : BaseService, IUserService
|
public class UserService : BaseService, IUserService
|
||||||
{
|
{
|
||||||
private readonly IRepository<User> _userRepository;
|
private readonly IRepository<User> _userRepository;
|
||||||
|
|
||||||
private readonly IMailVerificationService _mailVerificationService;
|
private readonly IMailVerificationService _mailVerificationService;
|
||||||
private readonly IRepository<VerificationCode> _verificationCodeRepository;
|
private readonly IRepository<VerificationCode> _verificationCodeRepository;
|
||||||
private readonly IRepository<Doctor> _doctorRepository;
|
private readonly IRepository<Doctor> _doctorRepository;
|
||||||
private readonly IRepository<TrialUser> _userTrialRepository;
|
private readonly IRepository<TrialUser> _userTrialRepository;
|
||||||
private readonly IRepository<UserLog> _userLogRepository;
|
private readonly IRepository<UserLog> _userLogRepository;
|
||||||
|
private readonly IRepository<UserPassWordLog> _userPassWordLogRepository;
|
||||||
private readonly IDistributedLockProvider _distributedLockProvider;
|
private readonly IDistributedLockProvider _distributedLockProvider;
|
||||||
private readonly IEasyCachingProvider _cache;
|
private readonly IEasyCachingProvider _cache;
|
||||||
private readonly IReadingImageTaskService _readingImageTaskService;
|
private readonly IReadingImageTaskService _readingImageTaskService;
|
||||||
|
@ -44,12 +45,13 @@ namespace IRaCIS.Application.Services
|
||||||
IReadingImageTaskService readingImageTaskService,
|
IReadingImageTaskService readingImageTaskService,
|
||||||
IRepository<TrialUser> userTrialRepository,
|
IRepository<TrialUser> userTrialRepository,
|
||||||
IOptionsMonitor<ServiceVerifyConfigOption> verifyConfig,
|
IOptionsMonitor<ServiceVerifyConfigOption> verifyConfig,
|
||||||
IRepository<UserLog> userLogRepository
|
IRepository<UserLog> userLogRepository,
|
||||||
|
IRepository<UserPassWordLog> userPassWordLogRepository
|
||||||
,
|
,
|
||||||
IDistributedLockProvider distributedLockProvider)
|
IDistributedLockProvider distributedLockProvider)
|
||||||
{
|
{
|
||||||
_userLogRepository = userLogRepository;
|
_userLogRepository = userLogRepository;
|
||||||
|
this._userPassWordLogRepository = userPassWordLogRepository;
|
||||||
_verifyConfig = verifyConfig;
|
_verifyConfig = verifyConfig;
|
||||||
_cache = cache;
|
_cache = cache;
|
||||||
this._readingImageTaskService = readingImageTaskService;
|
this._readingImageTaskService = readingImageTaskService;
|
||||||
|
@ -96,9 +98,6 @@ namespace IRaCIS.Application.Services
|
||||||
{
|
{
|
||||||
//var dbUser = (await _userRepository.FirstOrDefaultAsync(t => t.Id == userId)).IfNullThrowException();
|
//var dbUser = (await _userRepository.FirstOrDefaultAsync(t => t.Id == userId)).IfNullThrowException();
|
||||||
|
|
||||||
if (_verifyConfig.CurrentValue.OpenUserComplexPassword)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (oldPwd != null && oldPwd == newPwd)
|
if (oldPwd != null && oldPwd == newPwd)
|
||||||
{
|
{
|
||||||
//---新密码与旧密码相同。
|
//---新密码与旧密码相同。
|
||||||
|
@ -120,9 +119,27 @@ namespace IRaCIS.Application.Services
|
||||||
throw new BusinessValidationFailedException(_localizer["User_NewOldPwdSame"]);
|
throw new BusinessValidationFailedException(_localizer["User_NewOldPwdSame"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var passWordList = await _userPassWordLogRepository.Where(x => x.UserId == userId).OrderByDescending(x => x.CreateTime).Take(2).ToListAsync();
|
||||||
|
if (passWordList.Any(x => x.PassWord == newPwd))
|
||||||
|
{
|
||||||
|
throw new BusinessValidationFailedException(_localizer["User_PassWordRepeat"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await _userPassWordLogRepository.AddAsync(new UserPassWordLog()
|
||||||
|
{
|
||||||
|
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
PassWord = oldPwd,
|
||||||
|
UserId = userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
await _userRepository.BatchUpdateNoTrackingAsync(x => x.Id == userId, x => new User()
|
||||||
|
{
|
||||||
|
LastChangePassWordTime = DateTime.Now,
|
||||||
|
});
|
||||||
|
await _userPassWordLogRepository.SaveChangesAsync();
|
||||||
|
|
||||||
|
|
||||||
await Task.CompletedTask;
|
await Task.CompletedTask;
|
||||||
|
|
||||||
|
|
||||||
|
@ -650,7 +667,7 @@ namespace IRaCIS.Application.Services
|
||||||
|
|
||||||
if (failCount >= maxFailures)
|
if (failCount >= maxFailures)
|
||||||
{
|
{
|
||||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = Guid.Empty, OptUserId = Guid.Empty, LoginFaildName = userName,LoginPassword=password, OptType = UserOptType.AccountLocked }, true);
|
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = Guid.Empty, OptUserId = Guid.Empty, LoginFaildName = userName, LoginPassword = password, OptType = UserOptType.AccountLocked }, true);
|
||||||
|
|
||||||
//$"密码连续错误{maxFailures}次,当前账号已被限制登录,请等待 {lockoutMinutes} 分钟后再试。"
|
//$"密码连续错误{maxFailures}次,当前账号已被限制登录,请等待 {lockoutMinutes} 分钟后再试。"
|
||||||
throw new BusinessValidationFailedException(_localizer["User_ErrorLimit", maxFailures, lockoutMinutes]);
|
throw new BusinessValidationFailedException(_localizer["User_ErrorLimit", maxFailures, lockoutMinutes]);
|
||||||
|
@ -668,7 +685,7 @@ namespace IRaCIS.Application.Services
|
||||||
failCount++;
|
failCount++;
|
||||||
_cache.Set(cacheKey, failCount, TimeSpan.FromMinutes(lockoutMinutes));
|
_cache.Set(cacheKey, failCount, TimeSpan.FromMinutes(lockoutMinutes));
|
||||||
|
|
||||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = Guid.Empty, OptUserId=Guid.Empty, LoginFaildName = userName, LoginPassword = password, OptType = UserOptType.AccountOrPasswordError }, true);
|
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = Guid.Empty, OptUserId = Guid.Empty, LoginFaildName = userName, LoginPassword = password, OptType = UserOptType.AccountOrPasswordError }, true);
|
||||||
|
|
||||||
return ResponseOutput.NotOk(_localizer["User_CheckNameOrPw"], new LoginReturnDTO());
|
return ResponseOutput.NotOk(_localizer["User_CheckNameOrPw"], new LoginReturnDTO());
|
||||||
|
|
||||||
|
@ -684,14 +701,44 @@ namespace IRaCIS.Application.Services
|
||||||
return ResponseOutput.NotOk(_localizer["User_Disabled"], new LoginReturnDTO());
|
return ResponseOutput.NotOk(_localizer["User_Disabled"], new LoginReturnDTO());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//超过90天没修改密码
|
||||||
|
if (loginUser.LastChangePassWordTime != null && DateTime.Now.AddDays(-90) > loginUser.LastChangePassWordTime.Value)
|
||||||
|
{
|
||||||
|
loginUser.LoginState = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//登录成功 清除缓存
|
//登录成功 清除缓存
|
||||||
_cache.Set(cacheKey, 0, TimeSpan.FromMinutes(lockoutMinutes));
|
_cache.Set(cacheKey, 0, TimeSpan.FromMinutes(lockoutMinutes));
|
||||||
|
|
||||||
|
var lastLoginLog = await _userLogRepository.Where(x => x.LoginUserId == loginUser.Id).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync();
|
||||||
|
if (lastLoginLog!=null)
|
||||||
|
{
|
||||||
|
if (lastLoginLog.IP != _userInfo.IP)
|
||||||
|
{
|
||||||
|
loginUser.LoginState = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = loginUser.Id, OptUserId = loginUser.Id, OptType = UserOptType.Login }, true);
|
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = loginUser.Id, OptUserId = loginUser.Id, OptType = UserOptType.Login }, true);
|
||||||
|
|
||||||
userLoginReturnModel.BasicInfo = loginUser;
|
userLoginReturnModel.BasicInfo = loginUser;
|
||||||
|
|
||||||
|
if (loginUser.LastChangePassWordTime == null)
|
||||||
|
{
|
||||||
|
await _userRepository.BatchUpdateNoTrackingAsync(x => x.Id == loginUser.Id, x => new User()
|
||||||
|
{
|
||||||
|
LastChangePassWordTime = DateTime.Now
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 登录 清除缓存
|
// 登录 清除缓存
|
||||||
//_cache.Remove(userLoginReturnModel.BasicInfo.Id.ToString());
|
//_cache.Remove(userLoginReturnModel.BasicInfo.Id.ToString());
|
||||||
|
|
|
@ -78,6 +78,11 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
|
|
||||||
public string EmailToken { get; set; } = string.Empty;
|
public string EmailToken { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上一次修改密码的时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? LastChangePassWordTime { get; set; }
|
||||||
|
|
||||||
//医生生成账号后,会有值
|
//医生生成账号后,会有值
|
||||||
public Guid? DoctorId { get; set; }
|
public Guid? DoctorId { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
// 此代码由T4模板自动生成 byzhouhang 20210918
|
||||||
|
// 生成时间 2024-05-07 13:47:08
|
||||||
|
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||||
|
using System;
|
||||||
|
using IRaCIS.Core.Domain.Share;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
namespace IRaCIS.Core.Domain.Models
|
||||||
|
{
|
||||||
|
///<summary>
|
||||||
|
///UserPassWordLog
|
||||||
|
///</summary>
|
||||||
|
[Table("UserPassWordLog")]
|
||||||
|
public class UserPassWordLog : Entity, IAuditAdd
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户Id
|
||||||
|
/// </summary>
|
||||||
|
public Guid UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 密码
|
||||||
|
/// </summary>
|
||||||
|
public string PassWord { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建日期
|
||||||
|
/// </summary>
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建人
|
||||||
|
/// </summary>
|
||||||
|
public Guid CreateUserId { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -325,6 +325,8 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
|
|
||||||
public virtual DbSet<User> User { get; set; }
|
public virtual DbSet<User> User { get; set; }
|
||||||
|
|
||||||
|
public virtual DbSet<UserPassWordLog> UserPassWordLog { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<TrialSiteUserSurvey> TrialSiteUserSurvey { get; set; }
|
public virtual DbSet<TrialSiteUserSurvey> TrialSiteUserSurvey { get; set; }
|
||||||
public virtual DbSet<TrialSiteEquipmentSurvey> TrialSiteEquipmentSurvey { get; set; }
|
public virtual DbSet<TrialSiteEquipmentSurvey> TrialSiteEquipmentSurvey { get; set; }
|
||||||
public virtual DbSet<TrialSiteSurvey> TrialSiteSurvey { get; set; }
|
public virtual DbSet<TrialSiteSurvey> TrialSiteSurvey { get; set; }
|
||||||
|
|
|
@ -33,6 +33,11 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
CloseCurrentWindows = 6,
|
CloseCurrentWindows = 6,
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// IP不一致
|
||||||
|
/// </summary>
|
||||||
|
IpDiscrepancy = 7,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//在其他地方登陆,被迫下线
|
//在其他地方登陆,被迫下线
|
||||||
|
@ -40,6 +45,11 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
|
|
||||||
AutoLoginOut = -2,
|
AutoLoginOut = -2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 需要修改密码
|
||||||
|
/// </summary>
|
||||||
|
NeedChangePassWord=-3,
|
||||||
|
|
||||||
//没有带token访问(未登陆)
|
//没有带token访问(未登陆)
|
||||||
NoToken = 10,
|
NoToken = 10,
|
||||||
|
|
||||||
|
|
|
@ -128,9 +128,9 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
// return new ResponseOutput<T>().Ok(data, msg);
|
// return new ResponseOutput<T>().Ok(data, msg);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
public static IResponseOutput<T> Ok<T>(T data = default, object otherData = default, string msg = "")
|
public static IResponseOutput<T> Ok<T>(T data = default, object otherData = default, string msg = "", ApiResponseCodeEnum code = ApiResponseCodeEnum.OK)
|
||||||
{
|
{
|
||||||
return new ResponseOutput<T>().Ok(data, otherData, msg);
|
return new ResponseOutput<T>().Ok(data, otherData, msg, code);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 成功
|
/// 成功
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<#+
|
<#+
|
||||||
public class config
|
public class config
|
||||||
{
|
{
|
||||||
public static readonly string ConnectionString = "Server=123.56.94.154,1435;Database=Test_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true";
|
public static readonly string ConnectionString = "Server=106.14.89.110,1435;Database=Test_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true";
|
||||||
public static readonly string DbDatabase = "Test_IRC";
|
public static readonly string DbDatabase = "Test_IRC";
|
||||||
//表名称用字符串,拼接
|
//表名称用字符串,拼接
|
||||||
public static readonly string TableName = "EnrollReadingCriterion";
|
public static readonly string TableName = "UserPassWordLog";
|
||||||
//具体文件里面 例如service 可以配置是否分页
|
//具体文件里面 例如service 可以配置是否分页
|
||||||
}
|
}
|
||||||
#>
|
#>
|
||||||
|
|
Loading…
Reference in New Issue