[add] sui page debug log

This commit is contained in:
Max 2023-10-28 16:41:52 +08:00
parent b479bd3ff3
commit 89fbbdf314
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)
uid := fmt.Sprintf("%d", id)
subject := "User Token"
audience := "Xiang Metadata Admin Panel"
audience := "Yao Process utils.jwt.Make"
issuer := fmt.Sprintf("xiang:%d", id)
if v, has := option["subject"]; has {
subject = fmt.Sprintf("%v", v)
}
if v, has := option["audience"]; has {
audience = fmt.Sprintf("%v", v)
}
if v, has := option["issuer"]; has {
issuer = fmt.Sprintf("%v", v)
}
if v, has := option["sid"]; has {
sid = fmt.Sprintf("%v", v)
}
if v, has := option["timeout"]; has {
timeout = int64(any.Of(v).CInt())
}
expiresAt := now + timeout
if v, has := option["expires_at"]; has {
expiresAt = int64(any.Of(v).CInt())
}
if sid == "" {
sid = session.ID()
}
@ -107,11 +116,13 @@ func JwtMake(id int, data map[string]interface{}, option map[string]interface{},
Issuer: issuer, // 签发人
},
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
tokenString, err := token.SignedString([]byte(jwtSecret))
if err != nil {
exception.New("生成令牌失败", 500).Ctx(err).Throw()
exception.New("JWT Make Error: %s", 500, err.Error()).Throw()
}
return JwtToken{
Token: tokenString,
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 {
name := filepath.Base(file)
relPath := file
log.Debug("[PageTree] file: %s isdir: %v", relPath, isdir)
if isdir {
if strings.HasPrefix(name, "__") || name == ".tmp" {
@ -79,6 +80,8 @@ func (tmpl *Template) PageTree(route string) ([]*core.PageTreeNode, error) {
break
}
}
log.Debug("[PageTree] dirs: %s found: %v", dir, found)
// If not found, create a new directory node.
if !found {
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()
}
expiresAt := time.Now().Unix() + 3600
expiresAt := time.Now().Unix() + 3600*8
// token := MakeToken(row, expiresAt)
id := any.Of(row.Get("id")).CInt()