Fixes in routers for permissions

This commit is contained in:
Antonio de la Rosa 2022-04-30 23:19:21 +02:00
parent fa8277dfc6
commit 840f74f5c6

View file

@ -7,6 +7,8 @@ class Config {
static public $home_module='welcome'; static public $home_module='welcome';
static public $modules_allowed=['welcome' => false];
} }
function get_controller($controller, $args=[]) { function get_controller($controller, $args=[]) {
@ -49,8 +51,12 @@ function get_route($path_info) {
case 1: case 1:
$controller='modules/'.$arr_path[1].'/controllers/index.php'; $controller='modules/'.$arr_path[1].'/controllers/index.php';
echo 'pepe';
if(Config::$modules_allowed[$arr_path[1]]==true) {
return \PhangoApp\PhaRouter\get_controller($controller, []); return \PhangoApp\PhaRouter\get_controller($controller, []);
}
break; break;
@ -58,7 +64,11 @@ function get_route($path_info) {
$controller='modules/'.$arr_path[1].'/controllers/'.$arr_path[2].'.php'; $controller='modules/'.$arr_path[1].'/controllers/'.$arr_path[2].'.php';
return \PhangoApp\PhaRouter\get_controller($controller, []); if(Config::$modules_allowed[$arr_path[1]]==true) {
return \PhangoApp\PhaRouter\get_controller($controller, []);
}
break; break;
@ -66,9 +76,13 @@ function get_route($path_info) {
$controller='modules/'.$arr_path[1].'/controllers/'.$arr_path[2].'.php'; $controller='modules/'.$arr_path[1].'/controllers/'.$arr_path[2].'.php';
$args=array_slice($arr_path, 2, count($arr_path)); if(Config::$modules_allowed[$arr_path[1]]==true) {
return \PhangoApp\PhaRouter\get_controller($controller, $args); $args=array_slice($arr_path, 2, count($arr_path));
return \PhangoApp\PhaRouter\get_controller($controller, $args);
}
break; break;
@ -83,6 +97,14 @@ function get_route($path_info) {
} }
//If not return, page not found.
echo 'Page not found';
http_response_code(404);
exit(1);
} }