diff --git a/IRaCIS.Core.API/Controllers/ExtraController.cs b/IRaCIS.Core.API/Controllers/ExtraController.cs index f737fa776..79b7ad5d0 100644 --- a/IRaCIS.Core.API/Controllers/ExtraController.cs +++ b/IRaCIS.Core.API/Controllers/ExtraController.cs @@ -25,6 +25,7 @@ using RestSharp; using RestSharp.Authenticators; using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Net; using System.Net.Http; @@ -200,10 +201,20 @@ namespace IRaCIS.Api.Controllers var errorUrl = domainStrList[0] + "//" + domainStrList[2] + "/error"; + if (lang == "zh") + { + CultureInfo.CurrentCulture = new CultureInfo(StaticData.CultureInfo.zh_CN); + CultureInfo.CurrentUICulture = new CultureInfo(StaticData.CultureInfo.zh_CN); + } + else + { + CultureInfo.CurrentCulture = new CultureInfo(StaticData.CultureInfo.en_US); + CultureInfo.CurrentUICulture = new CultureInfo(StaticData.CultureInfo.en_US); + } if (!await _useRepository.AnyAsync(t => t.Id == Guid.Parse(userId) && t.EmailToken == token && t.IsFirstAdd)) { - decodeUrl = errorUrl + $"?lang={lang}&ErrorMessage={System.Web.HttpUtility.UrlEncode(lang == "zh" ? "您的初始化链接已过期" : "Error!The initialization link has expired.")} "; + decodeUrl = errorUrl + $"?lang={lang}&ErrorMessage={System.Web.HttpUtility.UrlEncode(I18n.T("UserRedirect_InitializationLinkExpire"))} "; } return Redirect(decodeUrl); diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index 6bf2ce9ea..701bd3a85 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -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(_mapper.ConfigurationProvider).FirstOrDefaultAsync(); + var loginUser = await _identityUserRepository.Where(u => (u.UserName.Equals(userName) || u.EMail.Equals(userName)) && u.Password == password).ProjectTo(_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;