mirror of
https://gitcode.com/flipped-aurora/gin-vue-admin.git
synced 2025-12-30 03:42:26 +00:00
fix: correct cookie maxAge calculation by using seconds instead of minutes
The SetToken function expects maxAge in seconds (standard for HTTP cookies), but the code was incorrectly dividing by 60, causing cookies to expire 60 times faster than intended. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -264,7 +264,7 @@ func (b *BaseApi) SetUserAuthority(c *gin.Context) {
|
||||
}
|
||||
c.Header("new-token", token)
|
||||
c.Header("new-expires-at", strconv.FormatInt(claims.ExpiresAt.Unix(), 10))
|
||||
utils.SetToken(c, token, int((claims.ExpiresAt.Unix()-time.Now().Unix())/60))
|
||||
utils.SetToken(c, token, int(claims.ExpiresAt.Unix()-time.Now().Unix()))
|
||||
response.OkWithMessage("修改成功", c)
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ func GetToken(c *gin.Context) string {
|
||||
global.GVA_LOG.Error("重新写入cookie token失败,未能成功解析token,请检查请求头是否存在x-token且claims是否为规定结构")
|
||||
return token
|
||||
}
|
||||
SetToken(c, token, int((claims.ExpiresAt.Unix()-time.Now().Unix())/60))
|
||||
SetToken(c, token, int(claims.ExpiresAt.Unix()-time.Now().Unix()))
|
||||
}
|
||||
return token
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user