chg: [routes] updated for default landing page

remotes/origin/main
iglocska 2020-06-21 21:27:40 +02:00
parent bdb005e341
commit 5b78e0d63a
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 5 additions and 4 deletions

View File

@ -44,26 +44,27 @@ use Cake\Routing\RouteBuilder;
*/ */
/** @var \Cake\Routing\RouteBuilder $routes */ /** @var \Cake\Routing\RouteBuilder $routes */
$routes->setRouteClass(DashedRoute::class); $routes->setRouteClass(DashedRoute::class);
$routes->scope('/', function (RouteBuilder $builder) { $routes->scope('/', function (RouteBuilder $builder) {
$builder->setExtensions(['json']); $builder->setExtensions(['json']);
// Register scoped middleware for in scopes. // Register scoped middleware for in scopes.
$builder->registerMiddleware('csrf', new CsrfProtectionMiddleware([ $builder->registerMiddleware('csrf', new CsrfProtectionMiddleware([
'httpOnly' => true, 'httpOnly' => true,
])); ]));
/* /*
* Apply a middleware to the current route scope. * Apply a middleware to the current route scope.
* Requires middleware to be registered through `Application::routes()` with `registerMiddleware()` * Requires middleware to be registered through `Application::routes()` with `registerMiddleware()`
* Dirty way of disabling the middleware if the AUTHORIZATION header is set
*/ */
$builder->applyMiddleware('csrf'); if (empty($_SERVER['HTTP_AUTHORIZATION'])) {
$builder->applyMiddleware('csrf');
}
/* /*
* Here, we are connecting '/' (base path) to a controller called 'Pages', * Here, we are connecting '/' (base path) to a controller called 'Pages',
* its action called 'display', and we pass a param to select the view file * its action called 'display', and we pass a param to select the view file
* to use (in this case, templates/Pages/home.php)... * to use (in this case, templates/Pages/home.php)...
*/ */
$builder->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']); $builder->connect('/', ['controller' => 'Instance', 'action' => 'home']);
/* /*
* ...and connect the rest of 'Pages' controller's URLs. * ...and connect the rest of 'Pages' controller's URLs.