Fix: rotate access token and add test

This commit is contained in:
2025-12-07 22:06:32 +08:00
parent 8d3cd0260e
commit 4714ff7f56
8 changed files with 52 additions and 12 deletions

View File

@@ -6,10 +6,12 @@ import (
"time"
"gitea.konchin.com/go2025/backend/models"
"gitea.konchin.com/go2025/backend/tracing"
"gitea.konchin.com/go2025/backend/types"
"github.com/golang-jwt/jwt/v5"
"github.com/spf13/viper"
"github.com/uptrace/bunrouter"
"go.uber.org/zap"
)
func (self *Handlers) CheckRefreshToken(
@@ -46,6 +48,10 @@ func (self *Handlers) CheckRefreshToken(
}
}
tracing.Logger.Ctx(ctx).
Debug("where is my fucking UserId",
zap.String("userId", claim.UserId))
// check time and refresh
timeLeft := claim.ExpiresAt.Time.Sub(time.Now()) / time.Second
if int64(timeLeft) < viper.GetInt64("refresh-token-timeout")/2 {