From 5313257dadcbb693fba57f27bf408140dc7848dc Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Wed, 6 Nov 2024 14:43:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/hdl/hdl_login.go | 6 +++++- app/mw/mw_auth.go | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/hdl/hdl_login.go b/app/hdl/hdl_login.go index 11d6c7b..4c344df 100644 --- a/app/hdl/hdl_login.go +++ b/app/hdl/hdl_login.go @@ -57,7 +57,11 @@ func Login(c *gin.Context) { return } if utils.Md5(req.PassWord) != admin.Password { - e.OutErr(c, e.ERR_INVALID_ARGS, "密码错误") + e.OutErr(c, 400, e.NewErr(400, "密码错误")) + return + } + if admin.State == 2 { + e.OutErr(c, 400, e.NewErr(400, "账号被禁用")) return } ip := utils.GetIP(c.Request) diff --git a/app/mw/mw_auth.go b/app/mw/mw_auth.go index 9e7b6cf..1c12e8e 100644 --- a/app/mw/mw_auth.go +++ b/app/mw/mw_auth.go @@ -20,6 +20,10 @@ func Auth(c *gin.Context) { return } } + if admin != nil && admin.State == 2 { + e.OutErr(c, e.ERR_TOKEN_AUTH, e.NewErr(401003, "账号已被禁用")) + return + } // 将当前请求的username信息保存到请求的上下文c上 c.Set("admin", admin) if len(newToken) > 0 {