# Starting Auth component from other controller than AppController gives false result

**URL:** <https://discourse.cakephp.org/t/starting-auth-component-from-other-controller-than-appcontroller-gives-false-result/2948>\
**Category:** Need Help\
**Created:** [July 30, 2017, 12:09pm UTC](https://discourse.cakephp.org/t/starting-auth-component-from-other-controller-than-appcontroller-gives-false-result/2948 "2017-07-30T12:09:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joostdb](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@joostdb](https://discourse.cakephp.org/u/joostdb)\
**Post date:** [July 30, 2017, 12:09pm UTC](https://discourse.cakephp.org/t/starting-auth-component-from-other-controller-than-appcontroller-gives-false-result/2948/1 "2017-07-30T12:09:48Z")

</div>

I am making a login for a part of a website. Therefore I don’t want to start the Auth in the AppController but in the actual Controller I need it in.

In PremiumController:

[…]

> use Cake\Controller\Component\AuthComponent;

[…]

> public function initialize()  
> {  
> parent::initialize();
> 
> ```
> $this->loadComponent('Auth', [
> 'Basic' => ['userModel' => 'Clients'],
> 'Form' => ['userModel' => 'Clients'],
> 'loginAction' => [
> 'controller' => 'Premium',
> 'action' => 'login',
> 'plugin' => false
> ],
> 'authError' => 'Unauthorized Access',
> 'authenticate' => [
> 'Form' => [
> 'fields' => [
> 'username' => 'naam',
> 'password' => 'pass'
> ],
> 'userModel'=>'Clients', //Other table than Users
> 'passwordHasher' => [
> 'className' => 'Premium', //use MD5
> ]
> ]
> ],
> 'loginRedirect' => [
> 'controller' => 'Premium',
> 'action' => 'dashboard'
> ],
> 'logoutRedirect' => [
> 'controller' => 'Search',
> 'action' => 'index'
> ]
> ]);
> 
> ```
> 
> }

[…] and lower the login part

```
public function login()
{
    if ($this->request->is('post')) {
        $user = $this->Auth->identify();
        if ($user) {
            $this->Auth->setUser($user);
            return $this->redirect($this->Auth->redirectUrl());
        }
        $this->Flash->error(__('Invalid username or password, try again'));
    }
}

```

I don’t get any result from this. The $user remains ‘false’

How can I make this work and is there a way to proper debug the Auth component?

---

<div class="post-metadata">

**Author:** ![joostdb](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@joostdb](https://discourse.cakephp.org/u/joostdb)\
**Post date:** [August 1, 2017, 8:30am UTC](https://discourse.cakephp.org/t/starting-auth-component-from-other-controller-than-appcontroller-gives-false-result/2948/2 "2017-08-01T08:30:52Z")

</div>

I found the solution myself.  
Here it is: [https://stackoverflow.com/a/45427769/485849](https://stackoverflow.com/a/45427769/485849)
