fix 调试登录

This commit is contained in:
ZJY 2021-09-25 10:34:03 +08:00
parent a5ff02010d
commit 789b21cca9
4 changed files with 76 additions and 1 deletions

View File

@ -1,6 +1,8 @@
package controllers
import (
"encoding/json"
"fmt"
"github.com/beego/beego/v2/core/logs"
"github.com/cdle/xdd/models"
)
@ -61,8 +63,28 @@ func (c *AccountController) GetUserInfo() {
cookie, err := models.GetJdCookie(pin)
if err != nil {
logs.Error(err)
result := Result{
Data: "null",
Code: 1,
Message: "查无匹配的pin",
}
jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[]
if errs != nil {
fmt.Println(errs.Error())
}
c.Ctx.WriteString(string(jsons))
} else {
result := Result{
Data: cookie.Query(),
Code: 0,
Message: "查询成功",
}
jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[]
if errs != nil {
fmt.Println(errs.Error())
}
c.Ctx.WriteString(string(jsons))
}
cookie.Query()
}

View File

@ -44,6 +44,26 @@ type Result struct {
var JdCookieRunners sync.Map
var jdua = models.GetUserAgent
//func (c *LoginController) GetQrcode1() {
// rsp, err := httplib.Get("https://api.kukuqaq.com/jd/qrcode").Response()
// if err != nil {
// logs.Info(err)
// }
// body, err1 := ioutil.ReadAll(rsp.Body)
// if err1 == nil {
// fmt.Println(string(body))
// }
// s := &models.QQuery{}
// if len(body) > 0 {
// json.Unmarshal(body, &s)
// }
// jsonByte, _ := json.Marshal(s)
// jsonStr := string(jsonByte)
// fmt.Printf("%v", jsonStr)
// c.Ctx.WriteString(`{"url":"` + "url" + `","img":"` + base64.StdEncoding.EncodeToString(data) + `"}`) //"data:image/png;base64," +
//
//}
func (c *LoginController) GetQrcode() {
if v := c.GetSession("jd_token"); v != nil {
token := v.(string)

View File

@ -53,6 +53,7 @@ func main() {
})
web.Router("/api/login/qrcode", &controllers.LoginController{}, "get:GetQrcode")
web.Router("/api/login/qrcode.png", &controllers.LoginController{}, "get:GetQrcode")
web.Router("/api/login/qrcode1", &controllers.LoginController{}, "get:GetQrcode1")
web.Router("/api/login/query", &controllers.LoginController{}, "get:Query")
web.Router("/api/login/cookie", &controllers.LoginController{}, "get:Cookie")
web.Router("/api/login/admin", &controllers.LoginController{}, "post:IsAdmin")

View File

@ -117,6 +117,38 @@ var codeSignals = []CodeSignal{
return Count()
},
},
{
Command: []string{"删除WCK"},
Admin: true,
Handle: func(sender *Sender) interface{} {
sender.handleJdCookies(func(ck *JdCookie) {
ck.Update(WsKey, "")
sender.Reply(fmt.Sprintf("已删除WCK,%s", ck.Nickname))
})
return nil
},
},
//{
// Command: []string{"qrcode", "扫码", "二维码", "scan"},
// Handle: func(sender *Sender) interface{} {
// rsp, err := httplib.Get("https://api.kukuqaq.com/jd/qrcode").Response()
// if err != nil {
// return nil
// }
// body, err1 := ioutil.ReadAll(rsp.Body)
// if err1 == nil {
// fmt.Println(string(body))
// }
// s := &QQuery{}
// if len(body) > 0 {
// json.Unmarshal(body, &s)
// }
// jsonByte, _ := json.Marshal(s)
// jsonStr := string(jsonByte)
// fmt.Printf("%v", jsonStr)
// return `{"url":"` + "http://www.baidu.com" + `","img":"` + s.Data.QqLoginQrcode.Bytes + `"}`
// },
//},
{
Command: []string{`raw ^(\d{11})$`},
Handle: func(s *Sender) interface{} {