go-quasar-partial-ssr/backend/internal/systemUtils/utils.go

22 lines
381 B
Go

package systemUtils
import (
"github.com/gofiber/fiber/v3"
"github.com/golang-jwt/jwt/v5"
)
type Claims struct {
Username string `json:"username"`
TokenType string `json:"type"`
jwt.RegisteredClaims
}
func ClaimsFromCtx(c fiber.Ctx) (*Claims, bool) {
val := c.Locals("authClaims")
if val == nil {
return nil, false
}
claims, ok := val.(*Claims)
return claims, ok
}