修改用户登录日志
parent
2a0ee12780
commit
c58e96bce7
|
@ -33,13 +33,12 @@ namespace IRaCIS.Core.Application.Service
|
|||
var userLogQueryable =
|
||||
|
||||
_userLogRepository
|
||||
.WhereIf(inQuery.TrialId != null, t => t.CreateUser.UserTrials.Any(c => c.TrialId == inQuery.TrialId && c.UserId == t.CreateUserId))
|
||||
.WhereIf(inQuery.TrialId != null, t => t.LoginUser.UserTrials.Any(c => c.TrialId == inQuery.TrialId && c.UserId == t.CreateUserId))
|
||||
.WhereIf(inQuery.OptType!=null ,t=>t.OptType==inQuery.OptType)
|
||||
.WhereIf(inQuery.BeginDate != null, t => t.CreateTime >= inQuery.BeginDate)
|
||||
.WhereIf(inQuery.EndDate != null, t => t.CreateTime <= inQuery.EndDate)
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.LoginName) , t => t.LoginName.Contains(inQuery.LoginName) )
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.IP), t => t.IP.Contains(inQuery.IP))
|
||||
.WhereIf(!string.IsNullOrEmpty(inQuery.LoginName), t => t.LoginName.Contains(inQuery.LoginName))
|
||||
.ProjectTo<UserLogView>(_mapper.ConfigurationProvider);
|
||||
|
||||
var pageList = await userLogQueryable.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? "Id" : inQuery.SortField,inQuery.Asc);
|
||||
|
|
|
@ -295,7 +295,7 @@ namespace IRaCIS.Application.Services
|
|||
IsFirstAdd = true
|
||||
});
|
||||
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, CreateUserId = _userInfo.Id, LoginName = _userInfo.UserName, IsSuccess = true, OptType = UserOptType.AdminResetPassword }, true);
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = _userInfo.Id, LoginName = _userInfo.UserName, IsSuccess = true, OptType = UserOptType.AdminResetPassword }, true);
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ namespace IRaCIS.Application.Services
|
|||
IsFirstAdd = false
|
||||
});
|
||||
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, CreateUserId = _userInfo.Id, LoginName =string.Empty,LoginPassword=newPwd, IsSuccess = true, OptType = UserOptType.ModifyPassword }, true);
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = _userInfo.Id, LoginName =string.Empty,LoginPassword=newPwd, IsSuccess = true, OptType = UserOptType.ModifyPassword }, true);
|
||||
|
||||
return ResponseOutput.Result(success);
|
||||
|
||||
|
@ -443,7 +443,7 @@ namespace IRaCIS.Application.Services
|
|||
IsFirstAdd = false
|
||||
});
|
||||
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, CreateUserId = _userInfo.Id, LoginName = _userInfo.UserName, IsSuccess = true, OptType = UserOptType.ModifyPassword }, true);
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = _userInfo.Id, LoginName = _userInfo.UserName, IsSuccess = true, OptType = UserOptType.ModifyPassword }, true);
|
||||
|
||||
return ResponseOutput.Result(success);
|
||||
|
||||
|
@ -647,7 +647,7 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
if (failCount >= maxFailures)
|
||||
{
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, CreateUserId = Guid.Empty, LoginName = userName,LoginPassword=password, IsSuccess = false, OptType = UserOptType.AccountLocked }, true);
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = Guid.Empty, LoginName = userName,LoginPassword=password, IsSuccess = false, OptType = UserOptType.AccountLocked }, true);
|
||||
|
||||
throw new BusinessValidationFailedException($"密码连续错误{maxFailures}次,当前账号已被限制登录,请等待 {lockoutMinutes} 分钟后再试。");
|
||||
}
|
||||
|
@ -682,7 +682,7 @@ namespace IRaCIS.Application.Services
|
|||
failCount++;
|
||||
_cache.Set(cacheKey, failCount, TimeSpan.FromMinutes(lockoutMinutes));
|
||||
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, CreateUserId = Guid.Empty, LoginName = userName, LoginPassword = password, IsSuccess = false, OptType = UserOptType.AccountOrPasswordError }, true);
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = Guid.Empty, LoginName = userName, LoginPassword = password, IsSuccess = false, OptType = UserOptType.AccountOrPasswordError }, true);
|
||||
|
||||
return ResponseOutput.NotOk(_localizer["User_CheckNameOrPw"], new LoginReturnDTO());
|
||||
|
||||
|
@ -700,7 +700,7 @@ namespace IRaCIS.Application.Services
|
|||
//登录成功 清除缓存
|
||||
_cache.Set(cacheKey, 0, TimeSpan.FromMinutes(lockoutMinutes));
|
||||
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, CreateUserId = loginUser.Id, LoginName = userName, IsSuccess = true, OptType = UserOptType.Login }, true);
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = loginUser.Id, LoginName = userName, IsSuccess = true, OptType = UserOptType.Login }, true);
|
||||
|
||||
userLoginReturnModel.BasicInfo = loginUser;
|
||||
|
||||
|
@ -715,7 +715,7 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
public async Task<IResponseOutput> LoginOut(Guid userId,string loginName)
|
||||
{
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, CreateUserId = userId, LoginName = loginName, IsSuccess = true, OptType = UserOptType.LoginOut },true);
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = userId, LoginName = loginName, IsSuccess = true, OptType = UserOptType.LoginOut },true);
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
|
|
@ -38,9 +38,10 @@ namespace IRaCIS.Core.Domain.Models
|
|||
|
||||
public bool IsSuccess { get; set; }
|
||||
|
||||
public Guid? LoginUserId { get;set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public User CreateUser { get; set; }
|
||||
public User LoginUser { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue