使用本地SID二次校验增强管理系统安全性

This commit is contained in:
GoEdgeLab
2024-04-08 10:24:10 +08:00
parent af4d19ee5a
commit fcd69a4e65
12 changed files with 195 additions and 24 deletions

View File

@@ -0,0 +1,34 @@
Tea.context(function () {
this.$delay(function () {
let sid = localStorage.getItem("sid")
let ip = localStorage.getItem("ip")
if (sid == null || sid.length == 0 || ip == null || ip.length == 0) {
window.location = "/logout"
return
}
this.$post("$")
.params({localSid: sid, "ip": ip})
.post()
.success(function (resp) {
if (!resp.data.isOk) {
window.location = "/logout"
return
}
// renew local data
localStorage.setItem("sid", resp.data.localSid)
localStorage.setItem("ip", resp.data.ip)
// redirect back (MUST delay)
this.$delay(function () {
if (this.from.length > 0) {
window.location = this.from
} else {
window.location = "/dashboard"
}
})
})
})
})