账号初始化链接过期+初始化不允许忘记密码修改密码
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-02-24 13:24:41 +08:00
parent 6d009c4f86
commit fc4ef6b939
2 changed files with 25 additions and 7 deletions
@@ -334,14 +334,21 @@ namespace IRaCIS.Core.Application.Service
}
////查找改邮箱或者手机的用户
var exist = await _identityUserRepository.AnyAsync(t => t.EMail == email && t.Status == UserStateEnum.Enable);
var existUser = await _identityUserRepository.Where(t => t.EMail == email && t.Status == UserStateEnum.Enable).FirstOrDefaultAsync();
if (!exist)
if (existUser==null)
{
//---邮箱错误。
return ResponseOutput.NotOk(_localizer["User_EmailError"]);
}
else
{
if (existUser.IsFirstAdd && existUser.UserName.IsNullOrEmpty())
{
return ResponseOutput.NotOk(_localizer["User_Notinitialized"]);
}
}
//验证码 6位
@@ -937,7 +944,7 @@ namespace IRaCIS.Core.Application.Service
var userLoginReturnModel = new IRCLoginReturnDTO();
var loginUser = await _identityUserRepository.Where(u => u.UserName.Equals(userName) && u.Password == password).ProjectTo<UserBasicInfo>(_mapper.ConfigurationProvider).FirstOrDefaultAsync();
var loginUser = await _identityUserRepository.Where(u => (u.UserName.Equals(userName) || u.EMail.Equals(userName)) && u.Password == password).ProjectTo<UserBasicInfo>(_mapper.ConfigurationProvider).FirstOrDefaultAsync();
var existUserLoginInfo = await _identityUserRepository.Where(u => u.UserName == userName).Select(t => new { t.LastLoginIP, t.LastChangePassWordTime, t.Id }).FirstOrDefaultAsync();
@@ -1013,13 +1020,13 @@ namespace IRaCIS.Core.Application.Service
await _identityUserRepository.BatchUpdateNoTrackingAsync(x => x.Id == loginUser.IdentityUserId, x => new IdentityUser()
{
LastLoginTime = DateTime.Now,
LastLoginIP=_userInfo.IP,
LastLoginIP = _userInfo.IP,
});
if (loginUser.Status == 0)
{
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = loginUser.IdentityUserId, ActionUserName = userName, OptType = UserOptType.LoginLockedAccount, IsLoginUncommonly = isLoginUncommonly }, true);
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = loginUser.IdentityUserId, ActionUserName = loginUser.UserName, OptType = UserOptType.LoginLockedAccount, IsLoginUncommonly = isLoginUncommonly }, true);
//---该用户已经被禁用。
return ResponseOutput.NotOk(_localizer["User_Disabled"], new IRCLoginReturnDTO());
@@ -1029,7 +1036,7 @@ namespace IRaCIS.Core.Application.Service
await _fusionCache.SetAsync(cacheKey, 0, TimeSpan.FromMinutes(lockoutMinutes));
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = loginUser.IdentityUserId, OptType = UserOptType.Login, IsLoginUncommonly = isLoginUncommonly }, true);
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = loginUser.IdentityUserId, ActionUserName=loginUser.UserName, OptType = UserOptType.Login, IsLoginUncommonly = isLoginUncommonly }, true);
userLoginReturnModel.BasicInfo = loginUser;