修复登录插入操作人异常问题

master
ZR20090193-陈敬勇 9 months ago
parent 31d3a18aa7
commit be19f22b69

@ -33,7 +33,7 @@ public class AspNetUser : IUser
if (_userId == null)
{
var claimValue = GetClaimValueByType("jti").FirstOrDefault();
_userId = claimValue != null ? claimValue.ObjToString() : "东胜软件";
_userId = claimValue != null ? claimValue.ObjToString() : "1288018625843826688";
}
return _userId;
}
@ -243,26 +243,29 @@ public class AspNetUser : IUser
var user = _accessor.HttpContext?.User;
if (user == null || !user.Claims.Any())
{
return GetDefaultUserInfo();
return null;
// return GetDefaultUserInfo();
}
var token = GetToken();
if (string.IsNullOrEmpty(token))
{
return GetDefaultUserInfo();
return null;
// return GetDefaultUserInfo();
}
var jwtHandler = new JwtSecurityTokenHandler();
if (!jwtHandler.CanReadToken(token))
{
return GetDefaultUserInfo();
return null;
// return GetDefaultUserInfo();
}
JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(token);
var userInfoJson = jwtToken.Claims.First().Value;
var userInfo = JsonConvert.DeserializeObject<UserInfo>(userInfoJson);
return userInfo ?? GetDefaultUserInfo();
return userInfo ?? null;
}
private UserInfo GetDefaultUserInfo()
@ -408,10 +411,10 @@ public class AspNetUser : IUser
public List<string> GetClaimValueByType(string ClaimType)
{
var claimsIdentity = GetClaimsIdentity();
if (claimsIdentity == null || !claimsIdentity.Any(item => item.Type == ClaimType))
{
return new List<string> { "jti", "TenantId", "CompanyId", "OrgId" }; // 返回包含默认参数的列表
}
// if (claimsIdentity == null || !claimsIdentity.Any(item => item.Type == ClaimType))
// {
// return new List<string> { "jti", "TenantId", "CompanyId", "OrgId" }; // 返回包含默认参数的列表
// }
return claimsIdentity.Where(item => item.Type == ClaimType).Select(item => item.Value).ToList();
}

@ -768,3 +768,52 @@
2024-03-08 19:44:35.5046 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-03-08 19:44:35.5466 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-08 19:44:35.6513 Info Configuration initialized.
2024-03-11 08:52:03.0094 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-11 08:52:03.1079 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-11 08:52:03.1245 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-11 08:52:03.1617 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-11 08:52:03.2309 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-03-11 08:52:03.2476 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-11 08:52:03.2769 Info Configuration initialized.
2024-03-11 09:01:12.6293 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-11 09:01:12.6911 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-11 09:01:12.7030 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-11 09:01:12.7328 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-11 09:01:12.7506 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-03-11 09:01:12.7630 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-11 09:01:12.7876 Info Configuration initialized.
2024-03-11 09:05:57.5342 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-11 09:05:57.5927 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-11 09:05:57.6512 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-11 09:05:57.7226 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-11 09:05:57.8090 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-03-11 09:05:57.8406 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-11 09:05:57.9361 Info Configuration initialized.
2024-03-11 09:15:08.5109 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-11 09:15:08.5633 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-11 09:15:08.6153 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-11 09:15:08.6701 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-11 09:15:08.7237 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-03-11 09:15:08.7401 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-11 09:15:08.8064 Info Configuration initialized.
2024-03-11 09:16:04.8906 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-11 09:16:04.9704 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-11 09:16:04.9910 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-11 09:16:05.0455 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-11 09:16:05.0854 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-03-11 09:16:05.1036 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-11 09:16:05.1392 Info Configuration initialized.
2024-03-11 09:27:43.8540 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-11 09:27:43.9296 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-11 09:27:43.9436 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-11 09:27:43.9715 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-11 09:27:43.9868 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-03-11 09:27:43.9932 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-11 09:27:44.0105 Info Configuration initialized.
2024-03-11 09:31:30.5271 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-11 09:31:30.5793 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-11 09:31:30.6353 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-11 09:31:30.6855 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-11 09:31:30.7954 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.MainApi\bin\Debug\net8.0\nlog.config
2024-03-11 09:31:30.8281 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-11 09:31:30.9202 Info Configuration initialized.

Loading…
Cancel
Save