From f18b8b06cc2aa0de7af9268ee20b7d79d224935b Mon Sep 17 00:00:00 2001 From: ZJY <764763903@qq.com> Date: Sun, 19 Sep 2021 10:23:02 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=AF=B9=E6=8E=A5=E7=9F=AD=E4=BF=A1?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/login.go | 104 +++++++++++++++++++++++++++++++++++++++++++ main.go | 1 + 2 files changed, 105 insertions(+) diff --git a/controllers/login.go b/controllers/login.go index 00f8c68..80a97cf 100644 --- a/controllers/login.go +++ b/controllers/login.go @@ -421,6 +421,110 @@ func (c *LoginController) CkLogin() { } +func (c *LoginController) SMSLogin() { + token := c.GetString("token") + cookie := c.GetString("ck") + //key := c.GetString("key") + //qq, _ := c.GetInt("qq") + //bz := c.GetString("bz") + //push := c.GetString("push") + logs.Info(cookie) + //logs.Info(key) + + if token == models.Config.ApiToken { + result := Result{ + Data: "null", + Code: 200, + Message: "添加成功", + } + jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[] + if errs != nil { + fmt.Println(errs.Error()) + } + c.Ctx.WriteString(string(jsons)) + + } else { + result := Result{ + Data: "null", + Code: 300, + Message: "Token错误", + } + jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[] + if errs != nil { + fmt.Println(errs.Error()) + } + c.Ctx.WriteString(string(jsons)) + + } + + //if key != "" && pin != "" { + // //ptKey := FetchJdCookieValue("pt_key", cookies) + // //ptPin := FetchJdCookieValue("pt_pin", cookies) + // ck := &models.JdCookie{ + // PtKey: key, + // PtPin: pin, + // Hack: models.False, + // QQ: qq, + // Note: bz, + // PushPlus: push, + // } + // if key != "" && pin != "" { + // if models.CookieOK(ck) { + // query := ck.Query() + // result := Result{ + // Data: query, + // Code: 0, + // } + // + // if !models.HasPin(pin) { + // models.NewJdCookie(ck) + // result.Message = fmt.Sprintf("添加成功") + // result.Data = ck.Query() + // jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[] + // if errs != nil { + // fmt.Println(errs.Error()) + // } + // c.Ctx.Redirect(200, "/userCenter") + // c.Ctx.WriteString(string(jsons)) + // } else if !models.HasKey(key) { + // ck, _ := models.GetJdCookie(pin) + // ck.InPool(key) + // result.Message = fmt.Sprintf("更新成功") + // result.Data = ck.Query() + // jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[] + // if errs != nil { + // fmt.Println(errs.Error()) + // } + // c.Ctx.WriteString(string(jsons)) + // } + // } else { + // result := Result{ + // Data: "null", + // Code: 1, + // Message: "CK过期", + // } + // jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[] + // if errs != nil { + // fmt.Println(errs.Error()) + // } + // c.Ctx.WriteString(string(jsons)) + // } + // } + //} else { + // result := Result{ + // Data: "null", + // Code: 2, + // Message: "ck格式错误", + // } + // jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[] + // if errs != nil { + // fmt.Println(errs.Error()) + // } + // c.Ctx.WriteString(string(jsons)) + //} + +} + func (c *LoginController) Cookie() { cookies := c.Ctx.Input.Header("Set-Cookie") pt_key := FetchJdCookieValue("pt_key", cookies) diff --git a/main.go b/main.go index edd0f39..b46fddc 100644 --- a/main.go +++ b/main.go @@ -57,6 +57,7 @@ func main() { web.Router("/api/login/cookie", &controllers.LoginController{}, "get:Cookie") web.Router("/api/login/admin", &controllers.LoginController{}, "post:IsAdmin") web.Router("/api/login/cklogin", &controllers.LoginController{}, "post:CkLogin") + web.Router("/api/login/smslogin", &controllers.LoginController{}, "post:SMSLogin") web.Router("/api/account", &controllers.AccountController{}, "get:List") web.Router("/api/account", &controllers.AccountController{}, "post:CreateOrUpdate") web.Router("/admin", &controllers.AccountController{}, "get:Admin")