测试。。。。请勿拉取更新
This commit is contained in:
parent
6343104559
commit
6fb4f1e6b5
@ -75,3 +75,7 @@ func (c *AccountController) CreateOrUpdate() {
|
||||
func (c *AccountController) Admin() {
|
||||
c.Ctx.WriteString(models.Admin)
|
||||
}
|
||||
|
||||
func (c *AccountController) IsAdmin() {
|
||||
c.SetSession("pin", "test")
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
"github.com/cdle/xdd/models"
|
||||
"github.com/go-playground/locales/zh"
|
||||
@ -112,10 +113,12 @@ func (c *BaseController) Logined() *BaseController {
|
||||
return c
|
||||
}
|
||||
if v := c.GetSession("pin"); v == nil {
|
||||
logs.Warn("test")
|
||||
c.Ctx.Redirect(302, "/")
|
||||
c.StopRun()
|
||||
} else {
|
||||
c.PtPin = v.(string)
|
||||
logs.Warn(v.(string))
|
||||
if strings.Contains(models.Config.Master, v.(string)) {
|
||||
c.Master = true
|
||||
}
|
||||
|
||||
2
main.go
2
main.go
@ -58,7 +58,7 @@ func main() {
|
||||
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{}, "get:Admin")
|
||||
web.Router("/admin", &controllers.AccountController{}, "post:IsAdmin")
|
||||
if models.Config.Static == "" {
|
||||
models.Config.Static = "./static"
|
||||
}
|
||||
|
||||
@ -76,8 +76,38 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
function login()
|
||||
{
|
||||
var xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||
var results = xmlhttp.responseText
|
||||
console.log(results)
|
||||
switch (results) {
|
||||
case "授权登录未确认":
|
||||
break;
|
||||
case "登录":
|
||||
hd.style.visibility = "hidden";
|
||||
qrcode.src = success
|
||||
clearInterval(timer)
|
||||
setTimeout(() => {
|
||||
window.location.href = "/admin"
|
||||
}, 1000);
|
||||
break;
|
||||
case "成功":
|
||||
hd.style.visibility = "hidden";
|
||||
qrcode.src = success
|
||||
clearInterval(timer)
|
||||
break;
|
||||
default:
|
||||
showQrcode()
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
xmlhttp.open("GET", "/api/login/query", true);
|
||||
xmlhttp.send();
|
||||
sessionStorage.setItem('pin',document.getElementById("pin").value);
|
||||
window.location.href = "/admin"
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user