diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index 4d28e9cc6..4358964e9 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -1002,7 +1002,9 @@ namespace IRaCIS.Core.Application.Service UserOptType.LoginLockedAccount }; - var lastLoginIPRegion = await _userLogRepository.Where(t => t.ActionUserName == loginUser.UserName && userOptTypes.Contains(t.OptType)) + var actionUserName= loginUser!= null ? loginUser.UserName : userName; + + var lastLoginIPRegion = await _userLogRepository.Where(t => t.ActionUserName == actionUserName && userOptTypes.Contains(t.OptType)) .OrderByDescending(t => t.CreateTime).Select(t => t.IPRegion).FirstOrDefaultAsync(); if (lastLoginIPRegion != string.Empty)