# How can I allow actions of other controllers, authentication plugin installed?

**URL:** <https://discourse.cakephp.org/t/how-can-i-allow-actions-of-other-controllers-authentication-plugin-installed/8587>\
**Category:** Uncategorized\
**Created:** [November 6, 2020, 3:58am UTC](https://discourse.cakephp.org/t/how-can-i-allow-actions-of-other-controllers-authentication-plugin-installed/8587 "2020-11-06T03:58:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cola](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@cola](https://discourse.cakephp.org/u/cola)\
**Post date:** [November 6, 2020, 3:58am UTC](https://discourse.cakephp.org/t/how-can-i-allow-actions-of-other-controllers-authentication-plugin-installed/8587/1 "2020-11-06T03:58:51Z")

</div>

Authentication plugin has been installed. If i browse actions of other controllers it redirects to /users/login. How can I allow actions of other controllers?

---

<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 6, 2020, 4:59am UTC](https://discourse.cakephp.org/t/how-can-i-allow-actions-of-other-controllers-authentication-plugin-installed/8587/2 "2020-11-06T04:59:18Z")

</div>

You want to allow certain actions for people who aren’t logged in? Or you are logged in but still getting redirected to the login page?

---

<div class="post-metadata">

**Author:** ![cola](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@cola](https://discourse.cakephp.org/u/cola)\
**Post date:** [November 6, 2020, 5:14am UTC](https://discourse.cakephp.org/t/how-can-i-allow-actions-of-other-controllers-authentication-plugin-installed/8587/3 "2020-11-06T05:14:06Z")

</div>

In PostsController i have added

```auto
    public function initialize(): void
    {
        parent::initialize();
        $this->Auth->allow(['index']);
    }

```

I get error:

```auto
Call to a member function allow() on null

```

How can I solve 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 6, 2020, 4:52pm UTC](https://discourse.cakephp.org/t/how-can-i-allow-actions-of-other-controllers-authentication-plugin-installed/8587/4 "2020-11-06T16:52:58Z")

</div>

Looks like you are mixing up the new plugin and the old component. See the documentation on [the component for the plugin](https://book.cakephp.org/authentication/2/en/authentication-component.html).

---

<div class="post-metadata">

**Author:** ![cimw](https://avatars.discourse-cdn.com/v4/letter/c/f07891/32.png) [@cimw](https://discourse.cakephp.org/u/cimw)\
**Post date:** [November 11, 2020, 10:57am UTC](https://discourse.cakephp.org/t/how-can-i-allow-actions-of-other-controllers-authentication-plugin-installed/8587/5 "2020-11-11T10:57:25Z")

</div>

I agree with Zuluru: according to the code you typed, you are using the Auth component, and if you use the component, the correct code is normaly (at least in Cake 1.3):  
$this-\>Auth-\>allow (‘index’);

But in order to be able to use this implementation, you need first to declare the component in the controller your are coding with the line:  
var $components = array (‘Auth’);

The message returned by the server means that it doesn’t know anything yet about ‘Auth’. That is why it says “call to a member function ‘allow()’ on null”: $this-\>Auth returns null considering the actual implementation of the controller you are working on.

---

<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 11, 2020, 3:17pm UTC](https://discourse.cakephp.org/t/how-can-i-allow-actions-of-other-controllers-authentication-plugin-installed/8587/6 "2020-11-11T15:17:25Z")

</div>

The correct code for using the new plugin’s component is different from what is required to use the old component.
