# Cake 4.5 using CakeDC/Users Missing Route

**URL:** <https://discourse.cakephp.org/t/cake-4-5-using-cakedc-users-missing-route/11684>\
**Category:** Need Help\
**Tags:** help\
**Created:** [November 17, 2023, 1:04pm UTC](https://discourse.cakephp.org/t/cake-4-5-using-cakedc-users-missing-route/11684 "2023-11-17T13:04:36Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![magic77](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@magic77](https://discourse.cakephp.org/u/magic77)\
**Post date:** [November 17, 2023, 1:04pm UTC](https://discourse.cakephp.org/t/cake-4-5-using-cakedc-users-missing-route/11684/1 "2023-11-17T13:04:36Z")

</div>

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:

```auto
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

```auto
$routes->scope('/', function (RouteBuilder $builder) {
        $builder->connect('/orders', ['controller' => 'Orders', 'action' => 'index']);
        $builder->connect('/pages/*', 'Pages::display');
        $builder->fallbacks();
    });

```

config/users

```auto
<?php
$config = [
    'Users' => [
        'Social' => [
            'login' => false,
            'validateSocialAccount' => false,
        ],
    ],
    'OneTimePasswordAuthenticator.login' => false,
];

return $config;

```

config/permissions

```auto
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

```auto
    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;
    }

```

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [November 17, 2023, 2:27pm UTC](https://discourse.cakephp.org/t/cake-4-5-using-cakedc-users-missing-route/11684/2 "2023-11-17T14:27:00Z")

</div>

Somewhere, you are specifying `['controller' => 'Orders', 'action' => 'index']` as the thing to redirect to. But it’s the users plugin that’s doing the redirect, so it’s defaulting to looking for it in that plugin. Set it to `['controller' => 'Orders', 'action' => 'index', 'plugin' => false]` to override that.

---

<div class="post-metadata">

**Author:** ![magic77](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@magic77](https://discourse.cakephp.org/u/magic77)\
**Post date:** [November 17, 2023, 2:44pm UTC](https://discourse.cakephp.org/t/cake-4-5-using-cakedc-users-missing-route/11684/3 "2023-11-17T14:44:28Z")

</div>

thanks, that helped to get the login workin, but after i log in i get this error thrown:

```auto
Table class for alias Users could not be found.

```

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [November 17, 2023, 4:10pm UTC](https://discourse.cakephp.org/t/cake-4-5-using-cakedc-users-missing-route/11684/4 "2023-11-17T16:10:11Z")

</div>

That’s a completely different problem, which you should post a new question for. When you do, you should include details like the stack trace and the specific code that’s causing the error, because the error message itself is nowhere near enough to go on.

---

<div class="post-metadata">

**Author:** ![magic77](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@magic77](https://discourse.cakephp.org/u/magic77)\
**Post date:** [November 19, 2023, 2:53pm UTC](https://discourse.cakephp.org/t/cake-4-5-using-cakedc-users-missing-route/11684/5 "2023-11-19T14:53:26Z")

</div>

@Zuluru After I restarted the server and cleared all caches, the problem with the table alias is gone and the assignment of users to orders works.  
But now the following error is thrown for the following routes

```auto
A route matching "array ( 'controller' => 'Orders', 'action' => 'index', 'plugin' => 'CakeDC/Users', '_ext' => NULL, )" could not be found.

```

at

```auto
/users/edit/ID
/users/view/ID

```

config/routes

```auto
<?php

use Cake\Routing\Route\DashedRoute;
use Cake\Routing\RouteBuilder;

return static function (RouteBuilder $routes) {
    $routes->setRouteClass(DashedRoute::class);
    $routes->scope('/', function (RouteBuilder $builder) {
        $builder->connect('/', ['controller' => 'Orders', 'action' => 'index', 'plugin' => false]);
        $builder->connect('/pages/*', 'Pages::display');
        $builder->fallbacks();
    });
};

```

config/users

```auto
<?php
$config = [
    'Users' => [
        'table' => 'CakeDC/Users.Users',
        'controller' => 'CakeDC/Users.Users',
        'Social' => [
            'login' => false,
            'validateSocialAccount' => false,
        ],
    ],
    'OneTimePasswordAuthenticator' => [
        'login' => false,
    ],
    'Auth' => [
        'AuthenticationComponent' => [
            'load' => true,
            'loginRedirect' => '/orders',
            'requireIdentity' => false,
        ],
    ],
];

return $config;

```

What could be the reason for this?

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [November 19, 2023, 4:52pm UTC](https://discourse.cakephp.org/t/cake-4-5-using-cakedc-users-missing-route/11684/6 "2023-11-19T16:52:53Z")

</div>

It could be exactly what I said above when you mentioned that error. You need `'plugin' => false` wherever you’re generating those order URLs.

---

<div class="post-metadata">

**Author:** ![magic77](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@magic77](https://discourse.cakephp.org/u/magic77)\
**Post date:** [November 19, 2023, 6:47pm UTC](https://discourse.cakephp.org/t/cake-4-5-using-cakedc-users-missing-route/11684/7 "2023-11-19T18:47:15Z")

</div>

but i already added this to routes

```auto
$builder->connect('/', ['controller' => 'Orders', 'action' => 'index', 'plugin' => false]);

```

therefor i don´t know where to put this too

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [November 19, 2023, 10:56pm UTC](https://discourse.cakephp.org/t/cake-4-5-using-cakedc-users-missing-route/11684/8 "2023-11-19T22:56:32Z")

</div>

It’s not the route that’s missing. Something somewhere is trying to generate a route (e.g. for a link) that does not have the `'plugin' => false` specified, and it’s failing as a result.

---

<div class="post-metadata">

**Author:** ![magic77](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@magic77](https://discourse.cakephp.org/u/magic77)\
**Post date:** [November 20, 2023, 11:53pm UTC](https://discourse.cakephp.org/t/cake-4-5-using-cakedc-users-missing-route/11684/9 "2023-11-20T23:53:07Z")

</div>

Sorry, I misunderstood you. There were a few links that had to be adjusted. It works now, thank you!
