Fix: rotate access token and add test
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user