持久化Token

This commit is contained in:
奶爸
2019-12-20 23:58:09 +08:00
parent af146872fe
commit 70f0e92343
13 changed files with 82 additions and 55 deletions

View File

@@ -26,18 +26,17 @@ func (cp *commonPage) serve() {
}
func (cp *commonPage) home(c *gin.Context) {
var admin *model.User
isLogin, ok := c.Get(model.CtxKeyIsUserLogin)
if ok && isLogin.(bool) {
admin = dao.Admin
}
dao.ServerLock.RLock()
defer dao.ServerLock.RUnlock()
c.HTML(http.StatusOK, "page/home", mygin.CommonEnvironment(c, gin.H{
"Admin": admin,
data := gin.H{
"Domain": dao.Conf.Site.Domain,
"Servers": dao.ServerList,
}))
}
u, ok := c.Get(model.CtxKeyAuthorizedUser)
if ok {
data["Admin"] = u
}
c.HTML(http.StatusOK, "page/home", mygin.CommonEnvironment(c, data))
}
var upgrader = websocket.Upgrader{}