Files
mcias/internal/ui/context.go
Kyle Isom 41d01edfb4 Migrate module path from kyle/ to mc/ org
All import paths updated from git.wntrmute.dev/kyle/mcias to
git.wntrmute.dev/mc/mcias to match the Gitea organization.
Includes main module and clients/go submodule.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 02:03:46 -07:00

31 lines
766 B
Go

package ui
import (
"context"
"git.wntrmute.dev/mc/mcias/internal/token"
)
// uiContextKey is the unexported type for UI context values, preventing
// collisions with keys from other packages.
type uiContextKey int
const (
uiClaimsKey uiContextKey = iota
)
// contextWithClaims stores validated JWT claims in the request context.
func contextWithClaims(ctx context.Context, claims *token.Claims) context.Context {
return context.WithValue(ctx, uiClaimsKey, claims)
}
// claimsFromContext retrieves the JWT claims stored by requireCookieAuth.
// Returns nil if no claims are present (unauthenticated request).
func claimsFromContext(ctx context.Context) *token.Claims {
c, ok := ctx.Value(uiClaimsKey).(*token.Claims)
if !ok {
return nil
}
return c
}