From 496a8b3a2d52837d57214841cce88bf6d7242a50 Mon Sep 17 00:00:00 2001 From: "chong.lu" Date: Tue, 7 Dec 2021 23:03:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9D=83=E9=99=90=E6=8B=A6?= =?UTF-8?q?=E6=88=AA=E9=97=AE=E9=A2=98=E3=80=81=E4=BC=98=E5=8C=96=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E7=99=BB=E5=BD=95=E5=8F=8A=E9=80=80=E5=87=BA=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=8E=A5=E5=8F=A3=E6=93=8D=E4=BD=9CRedis=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Web.Code/AuthorizationAttribute.cs | 2 +- Web/Controllers/LoginController.cs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Web.Code/AuthorizationAttribute.cs b/Web.Code/AuthorizationAttribute.cs index 785ef0f..325a1e2 100644 --- a/Web.Code/AuthorizationAttribute.cs +++ b/Web.Code/AuthorizationAttribute.cs @@ -25,7 +25,7 @@ namespace Web.Code if (userDto == null) throw new BusinessLogicException(401, "请先登录账号"); if (_power != null) { - if ((sbyte)userDto.Status>(sbyte)_power) + if ((sbyte)userDto.Power>(sbyte)_power) { throw new BusinessLogicException(403, $"您没有权限访问{path}接口!"); } diff --git a/Web/Controllers/LoginController.cs b/Web/Controllers/LoginController.cs index 3e45fc1..03e0d54 100644 --- a/Web/Controllers/LoginController.cs +++ b/Web/Controllers/LoginController.cs @@ -50,7 +50,8 @@ namespace Web.Controllers [Description("退出登录")] public async Task ExitLogin() { - _ = await _redis.DeleteAsync(UserToken); + var res = await _redis.DeleteAsync(UserToken); + if (!res) return new ModelStateResult("退出失败", 400); return new OkObjectResult("退出成功"); } /// @@ -61,7 +62,8 @@ namespace Web.Controllers [Description("刷新登录时间")] public async Task Refresh() { - await _redis.SetDateAsync(UserToken, DateTime.Now.AddMinutes(30)); + var res = await _redis.SetDateAsync(UserToken, DateTime.Now.AddMinutes(30)); + if (!res) return new ModelStateResult("刷新登陆时间失败", 400); return new OkObjectResult("刷新成功"); } } -- Gitee