Merge pull request #490 from trheyi/main

[add] sui page debug log
This commit is contained in:
Max 2023-10-28 16:42:40 +08:00 committed by GitHub
commit fbd663de42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View file

@ -67,25 +67,34 @@ func JwtMake(id int, data map[string]interface{}, option map[string]interface{},
timeout := int64(3600) timeout := int64(3600)
uid := fmt.Sprintf("%d", id) uid := fmt.Sprintf("%d", id)
subject := "User Token" subject := "User Token"
audience := "Xiang Metadata Admin Panel" audience := "Yao Process utils.jwt.Make"
issuer := fmt.Sprintf("xiang:%d", id) issuer := fmt.Sprintf("xiang:%d", id)
if v, has := option["subject"]; has { if v, has := option["subject"]; has {
subject = fmt.Sprintf("%v", v) subject = fmt.Sprintf("%v", v)
} }
if v, has := option["audience"]; has { if v, has := option["audience"]; has {
audience = fmt.Sprintf("%v", v) audience = fmt.Sprintf("%v", v)
} }
if v, has := option["issuer"]; has { if v, has := option["issuer"]; has {
issuer = fmt.Sprintf("%v", v) issuer = fmt.Sprintf("%v", v)
} }
if v, has := option["sid"]; has { if v, has := option["sid"]; has {
sid = fmt.Sprintf("%v", v) sid = fmt.Sprintf("%v", v)
} }
if v, has := option["timeout"]; has { if v, has := option["timeout"]; has {
timeout = int64(any.Of(v).CInt()) timeout = int64(any.Of(v).CInt())
} }
expiresAt := now + timeout expiresAt := now + timeout
if v, has := option["expires_at"]; has {
expiresAt = int64(any.Of(v).CInt())
}
if sid == "" { if sid == "" {
sid = session.ID() sid = session.ID()
} }
@ -107,11 +116,13 @@ func JwtMake(id int, data map[string]interface{}, option map[string]interface{},
Issuer: issuer, // 签发人 Issuer: issuer, // 签发人
}, },
} }
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
tokenString, err := token.SignedString([]byte(jwtSecret)) tokenString, err := token.SignedString([]byte(jwtSecret))
if err != nil { if err != nil {
exception.New("生成令牌失败", 500).Ctx(err).Throw() exception.New("JWT Make Error: %s", 500, err.Error()).Throw()
} }
return JwtToken{ return JwtToken{
Token: tokenString, Token: tokenString,
ExpiresAt: expiresAt, ExpiresAt: expiresAt,

View file

@ -55,6 +55,7 @@ func (tmpl *Template) PageTree(route string) ([]*core.PageTreeNode, error) {
tmpl.local.fs.Walk(tmpl.Root, func(root, file string, isdir bool) error { tmpl.local.fs.Walk(tmpl.Root, func(root, file string, isdir bool) error {
name := filepath.Base(file) name := filepath.Base(file)
relPath := file relPath := file
log.Debug("[PageTree] file: %s isdir: %v", relPath, isdir)
if isdir { if isdir {
if strings.HasPrefix(name, "__") || name == ".tmp" { if strings.HasPrefix(name, "__") || name == ".tmp" {
@ -79,6 +80,8 @@ func (tmpl *Template) PageTree(route string) ([]*core.PageTreeNode, error) {
break break
} }
} }
log.Debug("[PageTree] dirs: %s found: %v", dir, found)
// If not found, create a new directory node. // If not found, create a new directory node.
if !found { if !found {
newDir := &core.PageTreeNode{ newDir := &core.PageTreeNode{

View file

@ -99,7 +99,7 @@ func auth(field string, value string, password string, sid string) maps.Map {
exception.New("登录密码错误 (%v)", 403, value).Throw() exception.New("登录密码错误 (%v)", 403, value).Throw()
} }
expiresAt := time.Now().Unix() + 3600 expiresAt := time.Now().Unix() + 3600*8
// token := MakeToken(row, expiresAt) // token := MakeToken(row, expiresAt)
id := any.Of(row.Get("id")).CInt() id := any.Of(row.Get("id")).CInt()