diff --git a/IRaCIS.Core.API/Controllers/ExtraController.cs b/IRaCIS.Core.API/Controllers/ExtraController.cs index 12a487a6c..4f26e5863 100644 --- a/IRaCIS.Core.API/Controllers/ExtraController.cs +++ b/IRaCIS.Core.API/Controllers/ExtraController.cs @@ -136,7 +136,7 @@ namespace IRaCIS.Api.Controllers var loginReturn = new LoginReturnDTO() { BasicInfo = basicInfo }; - loginReturn.JWTStr = _tokenService.GetToken(new UserTokenInfo() { UserRoleId = basicInfo.Id }); + loginReturn.JWTStr = _tokenService.GetToken(new UserTokenInfo() { UserRoleId = basicInfo.IdentityUserId }); // 创建一个 CookieOptions 对象,用于设置 Cookie 的属性 @@ -228,7 +228,7 @@ namespace IRaCIS.Api.Controllers #endregion - var userId = returnModel.Data.BasicInfo.Id; + var userId = returnModel.Data.BasicInfo.IdentityUserId; if (_verifyConfig.CurrentValue.OpenLoginMFA) { @@ -277,7 +277,7 @@ namespace IRaCIS.Api.Controllers // 验证阅片休息时间 - await readingImageTaskService.ResetReadingRestTime(returnModel.Data.BasicInfo.Id); + await readingImageTaskService.ResetReadingRestTime(returnModel.Data.BasicInfo.IdentityUserId); await _fusionCache.SetAsync(CacheKeys.UserToken(userId), returnModel.Data.JWTStr, TimeSpan.FromDays(7)); diff --git a/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs b/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs index 648a5b261..824a66fd7 100644 --- a/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs +++ b/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs @@ -53,8 +53,7 @@ namespace IRaCIS.Application.Contracts public bool IsUserRoleDisabled { get; set; } - [Comment("多账号信息是否已经确认")] - public bool IsMutiAccountInfoConfirm { get; set; } + } public class LoginReturnDTO @@ -83,10 +82,12 @@ namespace IRaCIS.Application.Contracts { public Guid IdentityUserId { get; set; } + public Guid UserRoleId { get; set; } + public bool IsMutiAccount => AccountList?.Count > 1; public List AccountList { get; set; } - public Guid Id { get; set; } + public string UserName { get; set; } = string.Empty; public string FullName { get; set; } = string.Empty; public int? Sex { get; set; } // 1-男 2-女 diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index 8f8523edf..d4430bcb6 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -533,13 +533,11 @@ namespace IRaCIS.Core.Application.Service public async Task GetUser() { - var userQuery = _identityUserRepository.Where(t => t.Id == _userInfo.IdentityUserId).ProjectTo(_mapper.ConfigurationProvider); + var user = await _identityUserRepository.Where(t => t.Id == _userInfo.IdentityUserId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync(); - var userRole = await userQuery.FirstOrDefaultAsync(); + user.AccountList = await _userRepository.Where(t => t.IdentityUserId == _userInfo.IdentityUserId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - userRole.AccountList = await _userRepository.Where(t => t.IdentityUserId == _userInfo.IdentityUserId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - - return userRole; + return user; } ///// @@ -621,7 +619,7 @@ namespace IRaCIS.Core.Application.Service var success = await _identityUserRepository.SaveChangesAsync(); } - + await _mailVerificationService.AddUserSendEmailAsync(saveItem.Id, userAddModel.BaseUrl, userAddModel.RouteUrl); @@ -820,7 +818,7 @@ namespace IRaCIS.Core.Application.Service 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} 分钟后再试。" throw new BusinessValidationFailedException(_localizer["User_ErrorLimit", maxFailures, lockoutMinutes]); @@ -840,7 +838,7 @@ namespace IRaCIS.Core.Application.Service var errorPwdUserId = await _identityUserRepository.Where(u => u.UserName == userName).Select(t => t.Id).FirstOrDefaultAsync(); - await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = errorPwdUserId, OptUserId = errorPwdUserId, LoginFaildName = userName, LoginPassword = password, OptType = UserOptType.AccountOrPasswordError }, true); + //await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = errorPwdUserId, OptUserId = errorPwdUserId, LoginFaildName = userName, LoginPassword = password, OptType = UserOptType.AccountOrPasswordError }, true); return ResponseOutput.NotOk(_localizer["User_CheckNameOrPw"], new LoginReturnDTO()); @@ -848,7 +846,7 @@ namespace IRaCIS.Core.Application.Service if (loginUser.Status == 0) { - await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = loginUser.Id, OptUserId = loginUser.Id, LoginFaildName = userName, OptType = UserOptType.LoginLockedAccount }, true); + //await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginUserId = loginUser.IdentityUserId, OptUserId = loginUser.IdentityUserId, LoginFaildName = userName, OptType = UserOptType.LoginLockedAccount }, true); //---该用户已经被禁用。 return ResponseOutput.NotOk(_localizer["User_Disabled"], new LoginReturnDTO()); @@ -875,13 +873,13 @@ namespace IRaCIS.Core.Application.Service loginUser.LoginState = 1; } - 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.IdentityUserId, OptUserId = loginUser.IdentityUserId, OptType = UserOptType.Login }, true); userLoginReturnModel.BasicInfo = loginUser; if (loginUser.LastChangePassWordTime == null) { - await _identityUserRepository.BatchUpdateNoTrackingAsync(x => x.Id == loginUser.Id, x => new IdentityUser() + await _identityUserRepository.BatchUpdateNoTrackingAsync(x => x.Id == loginUser.IdentityUserId, x => new IdentityUser() { LastChangePassWordTime = DateTime.Now @@ -889,7 +887,7 @@ namespace IRaCIS.Core.Application.Service } - await _identityUserRepository.BatchUpdateNoTrackingAsync(x => x.Id == loginUser.Id, x => new IdentityUser() + await _identityUserRepository.BatchUpdateNoTrackingAsync(x => x.Id == loginUser.IdentityUserId, x => new IdentityUser() { LastLoginIP = iPRegion, LastLoginTime = DateTime.Now @@ -1059,7 +1057,6 @@ namespace IRaCIS.Core.Application.Service //返回临时token userLoginReturnModel.JWTStr = _tokenService.GetToken(new UserTokenInfo() { IdentityUserId = loginUser.IdentityUserId, UserName = userName }); - var userId = loginUser.Id; var identityUserId = loginUser.IdentityUserId; @@ -1085,7 +1082,7 @@ namespace IRaCIS.Core.Application.Service else { //正常登录才发送邮件 - await SendMFAEmail(userId, UserMFAType.Login); + await SendMFAEmail(identityUserId, UserMFAType.Login); } @@ -1093,7 +1090,7 @@ namespace IRaCIS.Core.Application.Service else { // 验证阅片休息时间 - await readingImageTaskService.ResetReadingRestTime(userLoginReturnModel.BasicInfo.Id); + await readingImageTaskService.ResetReadingRestTime(userLoginReturnModel.BasicInfo.IdentityUserId); await _fusionCache.SetAsync(CacheKeys.UserToken(identityUserId), userLoginReturnModel.JWTStr, TimeSpan.FromDays(7)); diff --git a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs index 8a7dd7c2b..11bcd4302 100644 --- a/IRaCIS.Core.Application/Service/Management/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Management/_MapConfig.cs @@ -87,7 +87,7 @@ namespace IRaCIS.Core.Application.Service // .ForMember(d => d.UserType, u => u.MapFrom(s => s.UserTypeRole.UserTypeShortName)) // .ForMember(d => d.CanEditUserType, u => u.MapFrom(s => !s.UserTrials.Any())); - CreateMap(); + CreateMap(); var token = string.Empty; var userId = Guid.Empty; @@ -140,8 +140,7 @@ namespace IRaCIS.Core.Application.Service CreateMap().ReverseMap(); - CreateMap() - .ForMember(d => d.UserRoleId, c => c.MapFrom(t => t.Id)); + CreateMap(); CreateMap() .ForMember(d => d.UserTypeShortName, c => c.MapFrom(t => t.UserTypeRole.UserTypeShortName)); @@ -150,7 +149,8 @@ namespace IRaCIS.Core.Application.Service CreateMap(); - CreateMap(); + CreateMap() + .ForMember(d => d.IdentityUserId, c => c.MapFrom(t => t.Id)); } }