feat: 更新SproutGate前后端代码

This commit is contained in:
2026-04-01 22:04:01 +08:00
parent 90590c7cb0
commit 650e1c7707
49 changed files with 3609 additions and 768 deletions

View File

@@ -8,17 +8,19 @@ import (
)
type Claims struct {
Account string `json:"account"`
Account string `json:"account"`
TokenEpoch int64 `json:"epoch"` // 与 users.token_epoch 一致;管理员封禁等操作会递增,旧 JWT 全部作废
jwt.RegisteredClaims
}
func GenerateToken(secret []byte, issuer string, account string, ttl time.Duration) (string, time.Time, error) {
func GenerateToken(secret []byte, issuer string, account string, tokenEpoch int64, ttl time.Duration) (string, time.Time, error) {
if account == "" {
return "", time.Time{}, errors.New("account is required")
}
expiresAt := time.Now().Add(ttl)
claims := Claims{
Account: account,
Account: account,
TokenEpoch: tokenEpoch,
RegisteredClaims: jwt.RegisteredClaims{
Issuer: issuer,
Subject: account,