refac: debt on role backend

This commit is contained in:
Florian Sylvain committed 2026-10-26 23:34:35 +01:00
1 parent de142f6c5f
commit a043f7f41a
130 files changed
+3591 -512

No files matched your search

+12 -5
View File
@@ -3,20 +3,27 @@ package access
import (
"RenewCMS/api/pkg/apperr"
"RenewCMS/internal/domain/role"
"RenewCMS/internal/infrastructure/useCases"
"context"
"errors"
"net/http"
)
type grantsContextKey struct{}
type Caller = useCases.ContentCaller
func NewContext(ctx context.Context, grants role.GrantSet) context.Context {
return context.WithValue(ctx, grantsContextKey{}, grants)
type callerContextKey struct{}
func WithCaller(ctx context.Context, caller Caller) context.Context {
return context.WithValue(ctx, callerContextKey{}, caller)
}
func CallerOf(r *http.Request) Caller {
caller, _ := r.Context().Value(callerContextKey{}).(Caller)
return caller
}
func Grants(r *http.Request) role.GrantSet {
grants, _ := r.Context().Value(grantsContextKey{}).(role.GrantSet)
return grants
return CallerOf(r).Grants
}
func WriteMissingPermission(w http.ResponseWriter, key string) {