From 348df768ff4a3d38db4de37742a7cb3cf1fff2c5 Mon Sep 17 00:00:00 2001 From: Marvin Date: Tue, 2 May 2023 22:59:51 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E5=89=8D=E5=88=A4=E7=BB=B4?= =?UTF-8?q?=E4=BF=AE=E8=BE=93=E5=85=A5=E7=9A=84UserID=E9=87=87=E7=94=A8?= =?UTF-8?q?=E8=AF=BB=E5=8F=96ClaimsIdentity=E7=9A=84UserID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AMESCoreStudio.Web/Controllers/LoginController.cs | 2 +- AMESCoreStudio.Web/Controllers/REPController.cs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/AMESCoreStudio.Web/Controllers/LoginController.cs b/AMESCoreStudio.Web/Controllers/LoginController.cs index f76006b6..0135f1da 100644 --- a/AMESCoreStudio.Web/Controllers/LoginController.cs +++ b/AMESCoreStudio.Web/Controllers/LoginController.cs @@ -126,7 +126,7 @@ namespace AMESCoreStudio.Web.Controllers HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity), new AuthenticationProperties { //获取或设置身份验证会话是否跨多个持久化要求 - IsPersistent = false, + IsPersistent = true, ExpiresUtc = null, //AllowRefresh = true, RedirectUri = "/Home/Framework" diff --git a/AMESCoreStudio.Web/Controllers/REPController.cs b/AMESCoreStudio.Web/Controllers/REPController.cs index 98b8a83d..3b53792c 100644 --- a/AMESCoreStudio.Web/Controllers/REPController.cs +++ b/AMESCoreStudio.Web/Controllers/REPController.cs @@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Hosting; using AMESCoreStudio.WebApi.DTO.AMES; using Newtonsoft.Json.Linq; +using Microsoft.AspNetCore.Authentication.Cookies; namespace AMESCoreStudio.Web.Controllers { @@ -567,7 +568,10 @@ namespace AMESCoreStudio.Web.Controllers { IResultModel result; var userID = ""; - userID = HttpContext.Request.Cookies["UserID4REP001"]; + + //userID = HttpContext.Request.Cookies["UserID4REP001"]; + userID = User.FindFirst("UserID")?.Value; + //HttpContext.Request.Cookies.TryGetValue("UserID", out userID); int user_id = 0; if (userID != null)