Ejemplo n.º 1
0
 function it_can_intercept_permission(User $user)
 {
     $user->abilities()->shouldBeCalled()->willReturn(['super-update']);
     $this->intercept('update', function ($user, $ability) {
         return $this->check('super-update');
     })->check('update')->shouldEqual(true);
 }
Ejemplo n.º 2
0
 /**
  * Check if user granted an ability
  * 
  * @param  string $ability
  * @return boolean
  */
 public function check($ability)
 {
     $return = true;
     $ability = $this->applyAlias($ability);
     if (!$this->applyPrecondition($ability)) {
         $return = false;
     }
     // Intercept was applied and return false
     if (!$this->applyIntercept($ability)) {
         $return = false;
     }
     // Checking if user has ability and the owner of the resource
     if (!in_array($ability, $this->user->abilities()) || !$this->applyForResource()) {
         $return = false;
     }
     return $return;
 }