# Site with cakedc users 9 gives error err\_too\_many\_redirects in cakephp 4.2

**URL:** <https://discourse.cakephp.org/t/site-with-cakedc-users-9-gives-error-err-too-many-redirects-in-cakephp-4-2/10293>\
**Category:** Need Help\
**Created:** [April 10, 2022, 5:28pm UTC](https://discourse.cakephp.org/t/site-with-cakedc-users-9-gives-error-err-too-many-redirects-in-cakephp-4-2/10293 "2022-04-10T17:28:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [April 10, 2022, 5:28pm UTC](https://discourse.cakephp.org/t/site-with-cakedc-users-9-gives-error-err-too-many-redirects-in-cakephp-4-2/10293/1 "2022-04-10T17:28:10Z")

</div>

When I login the site saves the cookie and then it gives the error err\_too\_many\_redirects, it doesn´t show the looged in page, and when the cookie is created I can’t enter to the site because it gives the error, because is trying to redirect to the login action of the cakedc users plugin and then to the root without the login action.  
This is the screenshot of the error:

 ![redirect](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/5/5fdd426cacf50c41d1af3be59ccab8cfe1fe86dc.png)  
How can I solve this error?

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [April 11, 2022, 3:24pm UTC](https://discourse.cakephp.org/t/site-with-cakedc-users-9-gives-error-err-too-many-redirects-in-cakephp-4-2/10293/2 "2022-04-11T15:24:41Z")

</div>

This means you are trying to access a page which is not allowed to be accessed without being logged in.

If you copied the `cakedc/users/config/permissions.php` to your own config folder make sure you allow the default login action for non authenticated users.

> <https://github.com/CakeDC/users/blob/master/config/permissions.php#L62>

Thats why there is the `bypassAuth` flag set [users/permissions.php at master · CakeDC/users · GitHub](https://github.com/CakeDC/users/blob/master/config/permissions.php#L88)

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [April 11, 2022, 4:01pm UTC](https://discourse.cakephp.org/t/site-with-cakedc-users-9-gives-error-err-too-many-redirects-in-cakephp-4-2/10293/3 "2022-04-11T16:01:26Z")

</div>

I have that, this is the code of cakedc/users/config/permissions.php

```auto
return [
    'CakeDC/Auth.permissions' => [
        //all bypass
        [
            'prefix' => false,
            'plugin' => 'CakeDC/Users',
            'controller' => 'Users',
            'action' => [
                // LoginTrait
                'socialLogin',
                'login',
                'logout',
                'socialEmail',
                'verify',
                // RegisterTrait
                'register',
                'validateEmail',
                // PasswordManagementTrait used in RegisterTrait
                'changePassword',
                'resetPassword',
                'requestResetPassword',
                // UserValidationTrait used in PasswordManagementTrait
                'resendTokenValidation',
                'linkSocial',
                //U2F actions
                'u2f',
                'u2fRegister',
                'u2fRegisterFinish',
                'u2fAuthenticate',
                'u2fAuthenticateFinish',
            ],
            'bypassAuth' => true,
        ],
        [
            'prefix' => false,
            'plugin' => 'CakeDC/Users',
            'controller' => 'SocialAccounts',
            'action' => [
                'validateAccount',
                'resendValidation',
            ],
            'bypassAuth' => true,
        ],
        //admin role allowed to all the things
        [
            'role' => 'admin',
            'prefix' => '*',
            'extension' => '*',
            'plugin' => '*',
            'controller' => '*',
            'action' => '*',
        ],
        //specific actions allowed for the all roles in Users plugin
        [
            'role' => '*',
            'plugin' => 'CakeDC/Users',
            'controller' => 'Users',
            'action' => ['profile', 'logout', 'linkSocial', 'callbackLinkSocial'],
        ],
        [
            'role' => '*',
            'plugin' => 'CakeDC/Users',
            'controller' => 'Users',
            'action' => 'resetOneTimePasswordAuthenticator',
            'allowed' => function (array $user, $role, \Cake\Http\ServerRequest $request) {
                $userId = \Cake\Utility\Hash::get($request->getAttribute('params'), 'pass.0');
                if (!empty($userId) && !empty($user)) {
                    return $userId === $user['id'];
                }

                return false;
            }
        ],
        //all roles allowed to Pages/display
        [
            'role' => '*',
            'controller' => 'Pages',
            'action' => 'display',
        ],
    ]
];
```

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [April 11, 2022, 8:01pm UTC](https://discourse.cakephp.org/t/site-with-cakedc-users-9-gives-error-err-too-many-redirects-in-cakephp-4-2/10293/4 "2022-04-11T20:01:14Z")

</div>

Try clearing your cache via `bin/cake cache clear_all`

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [April 11, 2022, 11:53pm UTC](https://discourse.cakephp.org/t/site-with-cakedc-users-9-gives-error-err-too-many-redirects-in-cakephp-4-2/10293/5 "2022-04-11T23:53:12Z")

</div>

Is a hosting service and I don’t have access to the linux console, is there another way to solve this?

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [April 12, 2022, 6:17am UTC](https://discourse.cakephp.org/t/site-with-cakedc-users-9-gives-error-err-too-many-redirects-in-cakephp-4-2/10293/6 "2022-04-12T06:17:34Z")

</div>

How are you planing to do cakephp updates via composer if you don’t have access to the CLI?

Anyways, the DebugKit has a `Cache` Tab where you can manually clear all cache configs.

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [April 12, 2022, 8:17pm UTC](https://discourse.cakephp.org/t/site-with-cakedc-users-9-gives-error-err-too-many-redirects-in-cakephp-4-2/10293/7 "2022-04-12T20:17:49Z")

</div>

I discovered what is happening, the problem is that I didn’t configure the file permissions.php with the role ‘user’, how can I configure that role to access a page with an authenticated user?

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [April 23, 2022, 6:49pm UTC](https://discourse.cakephp.org/t/site-with-cakedc-users-9-gives-error-err-too-many-redirects-in-cakephp-4-2/10293/8 "2022-04-23T18:49:43Z")

</div>

What role do I have to put in permissions.php for a user that has role “user” in users table?
