Current Path : /data/web/virtuals/51568/virtual/www/subdom/pomucky/src/middlewares/ |
Current File : /data/web/virtuals/51568/virtual/www/subdom/pomucky/src/middlewares/AuthMiddleware.php |
<?php namespace app\middlewares; use app\Application; use app\exceptions\ForbiddenException; class AuthMiddleware extends BaseMiddleware { protected $actions = []; public function __construct (array $actions = []) { $this->actions = $actions; } public function execute() { if (Application::isGuest()){ if (empty($this->actions) || in_array(Application::$app->controller->action, $this->actions)) { throw new ForbiddenException(); } } } }