Explorar o código

!612 HttpContext.User中ClaimConst.OrgId为null时设置为0
Merge pull request !612 from DaveMa/next

zuohuaijun %!s(int64=3) %!d(string=hai) anos
pai
achega
b1f0eb90e3
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      Admin.NET/Admin.NET.Core/Service/User/UserManager.cs

+ 5 - 1
Admin.NET/Admin.NET.Core/Service/User/UserManager.cs

@@ -42,7 +42,11 @@ public class UserManager : IScoped
 
     public long OrgId
     {
-        get => long.Parse(_httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.OrgId)?.Value);
+        get
+        {
+            var orgId = _httpContextAccessor.HttpContext?.User.FindFirst(ClaimConst.OrgId)?.Value;
+            return string.IsNullOrWhiteSpace(orgId) ? 0 : long.Parse(orgId);
+        }
     }
 
     public string OpenId