Fix context key mismatch - use typed contextKey consistently

This commit is contained in:
Leon Bösche
2026-01-09 20:26:55 +01:00
parent a9d205f454
commit 8114a3746b
3 changed files with 27 additions and 15 deletions

View File

@@ -54,6 +54,18 @@ const (
orgKey contextKey = "org"
)
// GetUserID retrieves the user ID from the request context
func GetUserID(ctx context.Context) (string, bool) {
userID, ok := ctx.Value(userKey).(string)
return userID, ok
}
// GetSession retrieves the session from the request context
func GetSession(ctx context.Context) (*database.Session, bool) {
session, ok := ctx.Value(sessionKey).(*database.Session)
return session, ok
}
// Auth middleware
func Auth(jwtManager *jwt.Manager, db *database.DB) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {