Ejemplo n.º 1
0
 /**
  * Checks if a user has one of the given cms right (XOR) and throw exception if not
  * @param array|string $rights Single right or array of rights
  * @throws \ch\timesplinter\core\HttpException
  */
 public function abortIfUserHasNotRights($rights)
 {
     foreach ((array) $rights as $r) {
         if ($this->auth->hasCmsRight($r) === true) {
             return;
         }
     }
     if (count($this->auth->getCmsRights()) !== 0) {
         $currentRights = implode(', ', $this->auth->getCmsRights());
     } else {
         $currentRights = 'no rights yet';
     }
     throw new HttpException('You have not the required rights for this action. Required right is one of: ' . implode(', ', (array) $rights) . '. You\'re current rights: ' . $currentRights, 401);
 }