I would like to redirect users to “/orders” after they have logged in. But when I call up the login page I get the following error message:
Missing Route: A route matching "array ( 'controller' => 'Orders', 'action' => 'index', 'plugin' => 'CakeDC/Users', '_ext' => NULL, )" could not be found.
But I can’t find out what the reason could be
config/routes
$routes->scope('/', function (RouteBuilder $builder) {
$builder->connect('/orders', ['controller' => 'Orders', 'action' => 'index']);
$builder->connect('/pages/*', 'Pages::display');
$builder->fallbacks();
});
config/users
<?php
$config = [
'Users' => [
'Social' => [
'login' => false,
'validateSocialAccount' => false,
],
],
'OneTimePasswordAuthenticator.login' => false,
];
return $config;
config/permissions
return [
'CakeDC/Auth.permissions' => [
[
'role' => '*',
'plugin' => 'DebugKit',
'controller' => '*',
'action' => '*',
'bypassAuth' => true,
],
[
'role' => '*',
'controller' => 'Users',
'action' => ['login', 'logout'],
'bypassAuth' => true,
],
[
'role' => 'admin',
'controller' => '*',
'action' => '*',
],
[
'role' => 'user',
'controller' => 'Orders',
'action' => ['index'],
],
[
'role' => 'user',
'controller' => 'Users',
'action' => ['edit'],
'allowed' => function (App\Model\Entity\User $user, $role, ServerRequest $request) {
$userId = Hash::get($request->getAttribute('params'), 'pass.0');
if (!empty($userId)) {
return $userId === $user['id'];
}
return false;
},
],
],
];
Application
public function bootstrap(): void
{
// Call parent to load bootstrap from files.
parent::bootstrap();
if (PHP_SAPI === 'cli') {
$this->bootstrapCli();
} else {
FactoryLocator::add(
'Table',
(new TableLocator())->allowFallbackClass(false)
);
}
/*
* Only try to load DebugKit in development mode
* Debug Kit should not be installed on a production system
*/
if (Configure::read('debug')) {
Configure::write('DebugKit.safeTld', ['de', 'com']);
Configure::write('DebugKit.variablesPanelMaxDepth', 10);
$this->addPlugin('DebugKit');
}
// Load more plugins here
// https://github.com/CakeDC/users/blob/11.next-cake4/Docs/Documentation/Installation.md#load-the-plugin
$this->addPlugin(\CakeDC\Users\Plugin::class);
Configure::write('Users.config', ['users']);
}
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
{
$middlewareQueue
->add(new ErrorHandlerMiddleware(Configure::read('Error'), $this))
->add(new AssetMiddleware([
'cacheTime' => Configure::read('Asset.cacheTime'),
]))
->add(new RoutingMiddleware($this))
->add(new BodyParserMiddleware())
->add(new CsrfProtectionMiddleware([
'httponly' => true,
]));
return $middlewareQueue;
}