-
Notifications
You must be signed in to change notification settings - Fork 7
Client Side Authorization Workflow
Erik Hetzner edited this page Apr 18, 2018
·
5 revisions
Or, "How does the Can Service on the client work"?
Undoubtedly you'll come across something like this in a handlebars template:
{{#if (can "edit" paper)}}
<a class="contributors-add" {{action "addContributors"}} id="nav-add-collaborators">Add Collaborators</a>
{{/if}}
What's actually happening?
- The 'can' helper asks the 'can' service to build an Ability based on the name of the action and the resource ('edit', and a paper in this case)
- The 'can' service looks for a Permission record in the store based
on the name of the resource. If it doesn't find one locally it
makes a request
to the rails api (see the PermissionsController). - The PermissionsController uses the Roles and Permissions system to build up a list of things the current user can do for the given resource, and returns it as a Permission record to the client.
- Once we pull down a Permission it stays in the store so we don't have to make a new request for each 'can' check
- The 'can' service returns the new Ability with its permissions set.
|
permission
lookup (application/gliffy+json)
permission
lookup.png (image/png)