21 lines
537 B
PHP
21 lines
537 B
PHP
<?php
|
|
|
|
namespace app\core\middlewares;
|
|
use app\core\Application;
|
|
use app\core\exceptions\ForbiddenException;
|
|
|
|
class AuthMiddleware extends BaseMiddleware{
|
|
public array $actions = [];
|
|
|
|
public function __construct(array $actions = []){
|
|
$this->actions = $actions;
|
|
}
|
|
|
|
public function execute(){
|
|
if(Application::isLoggedIn()){
|
|
if(empty($this->actions) || in_array(Application::$app->controller->action, $this->actions)){
|
|
throw new ForbiddenException;
|
|
}
|
|
}
|
|
}
|
|
} |