alepha@docs:~/docs/reference/providers$
cat OwnedResourceProvider.md | pretty
1 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({ entity: campaigns, param: "id", owner: "createdBy" })],7    handler: async () => this.owned.get<Campaign>(),8  });9}