Skip to content

Conversation

@andrewbytecoder
Copy link

  • 调整了SetToken函数中的过期时间单位,从秒转换为分钟
  • 确保新令牌的过期时间与配置保持一致- 修复了因时间单位不匹配导致的令牌提前失效问题
  • 和 GetToken中保持一致
func GetToken(c *gin.Context) string {
	token := c.Request.Header.Get("x-token")
	if token == "" {
		j := NewJWT()
		token, _ = c.Cookie("x-token")
		claims, err := j.ParseToken(token)
		if err != nil {
			global.GVA_LOG.Error("重新写入cookie token失败,未能成功解析token,请检查请求头是否存在x-token且claims是否为规定结构")
			return token
		}
		SetToken(c, token, int((claims.ExpiresAt.Unix()-time.Now().Unix())/60))
	}
	return token
}

- 调整了SetToken函数中的过期时间单位,从秒转换为分钟
- 确保新令牌的过期时间与配置保持一致- 修复了因时间单位不匹配导致的令牌提前失效问题
@pixelmaxQm pixelmaxQm changed the base branch from main to dev-287 November 3, 2025 05:28
@pixelmaxQm pixelmaxQm merged commit a1070a6 into flipped-aurora:dev-287 Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants