package member import ( "context" "fmt" ) type actorKey struct{} // Actor identifies the calling member (JWT middleware or dev headers). type Actor struct { TenantID string UID string } // WithActor stores tenant/uid on the context for member logic handlers. func WithActor(ctx context.Context, tenantID, uid string) context.Context { return context.WithValue(ctx, actorKey{}, Actor{TenantID: tenantID, UID: uid}) } // ActorFromContext reads the member actor injected by JWT middleware or dev headers. func ActorFromContext(ctx context.Context) (Actor, error) { v, ok := ctx.Value(actorKey{}).(Actor) if !ok || v.TenantID == "" || v.UID == "" { return Actor{}, fmt.Errorf("missing bearer token or X-Tenant-ID/X-UID headers") } return v, nil }