测试。。。。请勿拉取更新
This commit is contained in:
parent
9ada70bfc8
commit
bee6812543
@ -75,9 +75,3 @@ func (c *AccountController) CreateOrUpdate() {
|
||||
func (c *AccountController) Admin() {
|
||||
c.Ctx.WriteString(models.Admin)
|
||||
}
|
||||
|
||||
func (c *AccountController) IsAdmin() {
|
||||
var pin = c.GetString("pin")
|
||||
c.SetSession("pin", pin)
|
||||
c.Ctx.WriteString("登录")
|
||||
}
|
||||
|
||||
@ -324,6 +324,12 @@ func FetchJdCookieValue(key string, cookies string) string {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *LoginController) IsAdmin() {
|
||||
pin := c.GetString("pin")
|
||||
c.SetSession("pin", pin)
|
||||
c.Ctx.WriteString("登录")
|
||||
}
|
||||
|
||||
func (c *LoginController) Cookie() {
|
||||
cookies := c.Ctx.Input.Header("Set-Cookie")
|
||||
pt_key := FetchJdCookieValue("pt_key", cookies)
|
||||
|
||||
3
main.go
3
main.go
@ -55,10 +55,11 @@ func main() {
|
||||
web.Router("/api/login/qrcode.png", &controllers.LoginController{}, "get:GetQrcode")
|
||||
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")
|
||||
web.Router("/api/account", &controllers.AccountController{}, "get:List")
|
||||
web.Router("/api/account", &controllers.AccountController{}, "post:CreateOrUpdate")
|
||||
web.Router("/admin", &controllers.AccountController{}, "get:Admin")
|
||||
web.Router("/admin", &controllers.AccountController{}, "post:IsAdmin")
|
||||
web.Router("/admin", &controllers.AccountController{}, "get:Admin")
|
||||
if models.Config.Static == "" {
|
||||
models.Config.Static = "./static"
|
||||
}
|
||||
|
||||
@ -78,6 +78,7 @@
|
||||
function login()
|
||||
{
|
||||
const userName = document.querySelector('#pin').value
|
||||
sessionStorage.setItem('pin',document.getElementById("pin").value);
|
||||
var xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||
@ -104,7 +105,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
xmlhttp.open("POST","/admin", true);
|
||||
xmlhttp.open("POST","/api/login/admin", true);
|
||||
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
|
||||
xmlhttp.send("pin="+userName);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user