alepha@docs:~/docs/framework/reference/providers$
cat OwnedResourceProvider.md | pretty1 min read
Last commit:
#OwnedResourceProvider
#Import
typescript
1import { OwnedResourceProvider } from "alepha/security";
#Overview
Reads the resource resolved by $owns for the current request.
$owns already loads the row to make its access decision, so the handler
should not fetch it a second time. Inject this provider to read it back:
typescript
1class CampaignController {2 protected readonly owned = $inject(OwnedResourceProvider);3 4 read = $action({5 path: "/campaigns/:id",6 use: [$secure(), $owns({ repository: () => this.campaigns, param: "id", owner: "createdBy" })],7 handler: async () => this.owned.get<Campaign>(),8 });9}
Two rows, not one, once a gate declares through:
get()is the row the route param named (a quest).authority()is the row the decision was made against (its project) - the same row asget()when there is no hop, so a handler reads it the same way whether its endpoint hops or not.
find() / findAuthority() are the non-throwing forms, for a handler
legitimately reachable both with and without the gate.