From 4d914ead0ef870501aa4bcc2935400178ce59e53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Wed, 30 Aug 2023 07:50:06 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=E5=AE=8C=E5=96=84=E6=89=AB=E7=A0=81?= =?UTF-8?q?=E7=99=BB=E5=BD=95(=E7=94=9F=E6=88=90=E6=96=B0=E7=9A=84token)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZR.Admin.WebApi/Controllers/System/SysLoginController.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs b/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs index 2080ef9..d6511a3 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs @@ -247,6 +247,7 @@ namespace ZR.Admin.WebApi.Controllers.System /// [HttpPost("/ScanLogin")] [Log(Title = "扫码登录")] + [Verify] public IActionResult ScanLogin([FromBody] ScanDto dto) { if (dto == null) { return ToResponse(ResultCode.CUSTOM_ERROR, "扫码失败"); } @@ -259,14 +260,15 @@ namespace ZR.Admin.WebApi.Controllers.System { return ToResponse(ResultCode.LOGIN_ERROR, $"当前设备已被锁,剩余{Math.Round(ts.TotalMinutes, 0)}分钟"); } - var token = HttpContextExtension.GetToken(HttpContext); + //var token = HttpContextExtension.GetToken(HttpContext); + TokenModel tokenModel = JwtUtil.GetLoginUser(HttpContext); if (CacheService.GetScanLogin(dto.Uuid) is not null) { Dictionary dict = new() { }; dict.Add("status", "success"); - dict.Add("token", token.Replace("Bearer ", "")); + dict.Add("token", JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(tokenModel))); CacheService.SetScanLogin(dto.Uuid, dict); - //TODO 待优化,应该生成新的token + return SUCCESS(1); } return ToResponse(ResultCode.FAIL, "二维码已失效");