From 3a9f2ce8979a72dee006c6f3085789dd8a2a2929 Mon Sep 17 00:00:00 2001 From: ZJY <764763903@qq.com> Date: Sat, 6 Nov 2021 11:39:36 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=90=8E=E6=97=A0=E6=B3=95=E7=9F=AD=E4=BF=A1=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/login.go | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/controllers/login.go b/controllers/login.go index 4bd71a5..6211d3f 100644 --- a/controllers/login.go +++ b/controllers/login.go @@ -508,7 +508,7 @@ func (c *LoginController) SMSLogin() { } if ptKey != "" && ptPin != "" { if models.CookieOK(ck) { - if !models.HasPin(ptPin) { + if nck, err := models.GetJdCookie(ck.PtPin); err == nil { models.NewJdCookie(ck) ck.Query() if qq != "" { @@ -519,15 +519,13 @@ func (c *LoginController) SMSLogin() { (&models.JdCookie{}).Push(msg) } } else { - ck, _ := models.GetJdCookie(ptPin) - ck.InPool(ptKey) + nck.InPool(ptKey) if qq != "" && len(qq) > 6 { ck.Update(models.QQ, qq) } - msg := fmt.Sprintf("来自短信的更新,账号:%s,QQ: %v", ck.PtPin,qq) + msg := fmt.Sprintf("来自短信的更新,账号:%s,QQ: %v", ck.PtPin, qq) (&models.JdCookie{}).Push(msg) } - result := Result{ Data: "null", Code: 200, @@ -566,21 +564,21 @@ func (c *LoginController) SMSLogin() { msg := fmt.Sprintf("传入错误CK,请小心攻击,账号:%s", ck.PtPin) (&models.JdCookie{}).Push(msg) c.Ctx.WriteString(string(jsons)) - } - }else{ - result := Result{ + } + } else { + result := Result{ Data: "null", Code: 300, Message: "Token错误", - } - jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[] - if errs != nil { - fmt.Println(errs.Error()) - } - msg := fmt.Sprintf("传入错误Token,请小心攻击") - (&models.JdCookie{}).Push(msg) - c.Ctx.WriteString(string(jsons)) } + jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[] + if errs != nil { + fmt.Println(errs.Error()) + } + msg := fmt.Sprintf("传入错误Token,请小心攻击") + (&models.JdCookie{}).Push(msg) + c.Ctx.WriteString(string(jsons)) + } } func (c *LoginController) Cookie() {