To me, it would be easier just to have your methods authorized as to who can and can not do something.
In one system I have this logic:
* Bob is an admin
* Suzy is admin and does bookkeeping
* Mary is a bookkeeper only
If Bob is logged in, Bob can only do admin stuff and all access to user stuff. But Bob cannot mess with bookkeeping.
If Suzy is logged in she can access admin stuff and bookkeeping and accounting stuff.
If Mary is logged in she cannot mess with admin stuff, but has access to bookkeeping and accounting stuff.
So in pseudocode:
public function makeInvoice()
{
if (a required role of bkeep is not true here) { // bkeep = bookkeeper
return redirect('somewhere'); // whereever you redirect to if not authorized
}
// Rest of method here is accomplished if
// the logged in user has the required role of 'bkeep'.
}
But just suggestion and the way I like protecting methods.
A tip don't worry about the role, if super admin, boss, owner, janitor, it makes no difference.
What matters is:
- Can the current logged in user role have access to this method, it's (yes or no).
There are ways to be secure yet stay simple.
Also note:
The ui will probably be removed in future versions, best if you start using the newer jetstream / fortify now, just suggestion.
Otherwise will be harder migrating such a complex auth over. That's why I like keeping it simple.