From 18652c7177cb9b7394fd301edebd705543eb2483 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Mon, 15 Apr 2024 14:44:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9UserContext?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Common/UserManager/UserContext.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tiobon.Core.Common/UserManager/UserContext.cs b/Tiobon.Core.Common/UserManager/UserContext.cs index d39f6962..d52d0b7a 100644 --- a/Tiobon.Core.Common/UserManager/UserContext.cs +++ b/Tiobon.Core.Common/UserManager/UserContext.cs @@ -22,7 +22,7 @@ } } - private static Microsoft.AspNetCore.Http.HttpContext Context + public static Microsoft.AspNetCore.Http.HttpContext Context { get { @@ -33,7 +33,7 @@ /// /// 用户ID /// - public long? User_Id + public int User_Id { get { @@ -41,11 +41,11 @@ { //string aa = Context.User.FindFirstValue(ClaimTypes.NameIdentifier); string userId = Context?.User?.Identity?.Name; - return string.IsNullOrEmpty(userId) ? null : long.Parse(userId); + return string.IsNullOrEmpty(userId) ? 0 : int.Parse(userId); } catch (Exception) { - return null; //匿名访问 + return 0; //匿名访问 } } }