Advice on Laravel access right depending on entity status -


i've built management platform small business , working on v2 laravel 5.4.

the context following:

  • main managed entity mandate.
  • it has several items may managed(crud)
  • users can invited mandate , have different roles: responsible, main broker, sub broker.
  • some users "global" rights may have access mandates, secretary or ceo.
  • and part tricky part, access rights change depending on mandate status.

regarding global access rights, i've got covered activity/role based access.

mandate access rights stored in dedicated table storing following :

mandate_status_id role_identifier action_identifier is_authorized 

the way i'm handling access right on main entity bugging me , refactor it. what's bothering me on every access check have determine current user role regarding mandate being "touched". mandate acces rights table loaded singleton on every request.

i went @ first caching approach of rights/role showed limit when rights did not change after mandate status did.

i thinking building mandate access or mandate context when instanciating mandate model. prepare users having access , rights.

i'm open suggestion, if think i'm approaching wrong way please tell

when work permissions add boot method in authserviceprovider

public function boot(gatecontract $gate)     {         $this->registerpolicies();          $gate->before(function ($user, $ability) {             if (! $user->isactive()) {                 return false;             }              if ($user->isadmin()) {                 return true;             }              if ($user->issuperadmin()) {                 return true;             }              if (in_array($ability, $user->getabilities())) {                 return true;             }              return false;         }); 

and in user model have getabilities takes permissions db. , looks this:

public function getabilities() {     return $this->role->permissions->pluck('description')->toarray(); } 

now need create permissions model , set permissions in dataabse.

hope helps


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -