Skip to content

Commit

Permalink
Merge pull request #490 from trheyi/main
Browse files Browse the repository at this point in the history
[add] sui page debug log
  • Loading branch information
trheyi authored Oct 28, 2023
2 parents 9b41b08 + 89fbbdf commit fbd663d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
15 changes: 13 additions & 2 deletions helper/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions sui/storages/local/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion widgets/login/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit fbd663d

Please sign in to comment.