Admin Dashboard Permissions
Overview
Admin Dashboard utilizes Spree’s authorization system to control access to the different pages.
Restricting access to certain pages
Let’s assume you would like to add a new Role customer_service
with some limited access to Admin Panel only Orders section.
Create a new file called app/models/customer_service_ability.rb
Please familiarize yourself with CanCanCan syntax to understand can/cannot
methods more.
Now we need to inform Spree to use this ability, create another file app/models/spree/ability_decorator.rb
with contents:
This will automatically remove all other pages/navigation items from the sidebar for the customer_service
role.
You can be even more granular with the permissions by using the can
method.
This will restrict the access to the customer_service
role to only the Orders and Products pages. However they won’t be able to delete products or add new ones, just update existing ones.