facut pana la video 7

This commit is contained in:
Cerbu Andrei Mihnea
2023-05-10 00:47:48 +03:00
parent 1abdc313f4
commit 90f12ab916
40 changed files with 1644 additions and 41 deletions
@@ -0,0 +1,21 @@
<?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;
}
}
}
}