mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-06 13:40:06 +00:00
theme-mdui by @MikoyChinese
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/naiba/nezha/model"
|
||||
"github.com/naiba/nezha/service/dao"
|
||||
"github.com/naiba/nezha/service/singleton"
|
||||
)
|
||||
|
||||
type AuthorizeOption struct {
|
||||
@@ -38,11 +38,11 @@ func Authorize(opt AuthorizeOption) func(*gin.Context) {
|
||||
var isLogin bool
|
||||
|
||||
// 用户鉴权
|
||||
token, _ := c.Cookie(dao.Conf.Site.CookieName)
|
||||
token, _ := c.Cookie(singleton.Conf.Site.CookieName)
|
||||
token = strings.TrimSpace(token)
|
||||
if token != "" {
|
||||
var u model.User
|
||||
if err := dao.DB.Where("token = ?", token).First(&u).Error; err == nil {
|
||||
if err := singleton.DB.Where("token = ?", token).First(&u).Error; err == nil {
|
||||
isLogin = u.TokenExpired.After(time.Now())
|
||||
}
|
||||
if isLogin {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/naiba/nezha/model"
|
||||
"github.com/naiba/nezha/service/dao"
|
||||
"github.com/naiba/nezha/service/singleton"
|
||||
)
|
||||
|
||||
var adminPage = map[string]bool{
|
||||
@@ -20,15 +20,15 @@ var adminPage = map[string]bool{
|
||||
|
||||
func CommonEnvironment(c *gin.Context, data map[string]interface{}) gin.H {
|
||||
data["MatchedPath"] = c.MustGet("MatchedPath")
|
||||
data["Version"] = dao.Version
|
||||
data["Conf"] = dao.Conf
|
||||
data["Version"] = singleton.Version
|
||||
data["Conf"] = singleton.Conf
|
||||
// 是否是管理页面
|
||||
data["IsAdminPage"] = adminPage[data["MatchedPath"].(string)]
|
||||
// 站点标题
|
||||
if t, has := data["Title"]; !has {
|
||||
data["Title"] = dao.Conf.Site.Brand
|
||||
data["Title"] = singleton.Conf.Site.Brand
|
||||
} else {
|
||||
data["Title"] = fmt.Sprintf("%s - %s", t, dao.Conf.Site.Brand)
|
||||
data["Title"] = fmt.Sprintf("%s - %s", t, singleton.Conf.Site.Brand)
|
||||
}
|
||||
u, ok := c.Get(model.CtxKeyAuthorizedUser)
|
||||
if ok {
|
||||
|
||||
Reference in New Issue
Block a user