# Cakephp 3 auth not working

**URL:** <https://discourse.cakephp.org/t/cakephp-3-auth-not-working/1209>\
**Category:** Need Help\
**Created:** [September 21, 2016, 9:39am UTC](https://discourse.cakephp.org/t/cakephp-3-auth-not-working/1209 "2016-09-21T09:39:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gathuth](https://avatars.discourse-cdn.com/v4/letter/g/9e8a1a/32.png) [@Gathuth](https://discourse.cakephp.org/u/Gathuth)\
**Post date:** [September 21, 2016, 9:39am UTC](https://discourse.cakephp.org/t/cakephp-3-auth-not-working/1209/1 "2016-09-21T09:39:30Z")

</div>

i try to use Auth in cakephp3 but i got return error

i am sure that data correct

For note password field size is 255 char

sql log return only user\_mail filed where

```
  phi_members.user_mail = 'gathuth@gmail.com' 

```

why it not include user\_password !!  
and row result is 1

PhimembersController.php

```
    <?PHP

namespace App\Controller;
use App\Controller\AppController;
use Cake\Event\Event;

Class PhimembersController extends AppController {

    var $name="Phi_members";

    public $components = array('RequestHandler');

    public function index()
    {
echo'Hello World';
    }
    public function show() {

        $this->set('phi_members',$this->Phi_members->find('all'));

    }

public function initialize()
{   

    parent::initialize();
    $this->loadComponent('Flash');
    $this->loadComponent('Auth', [
                'loginRedirect' => [
                'action' => 'index'] , 'loginAction' => [
            'action' => 'login'
        ],
        'authenticate' => [
            'Form' => [
                'userModel' => 'phi_members',
                'fields' => ['username' => 'user_mail','password' => 'user_password']
            ]
        ]
    ]);
}

public function beforeFilter(Event $event)
    {
        $this->Auth->allow(['index', 'login']);
    }

        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'));
        }
    }

}

```

?\>

login.ctp

# \<?= $this-\>Flash-\>render('auth') ?\>
  
\<?= $this-\>Form-\>create(); ?\>  
  
\<?= \_\_('Please enter your username and password') ?\>  
\<?= $this-\>Form-\>input('user\_mail') ?\>  
\<?= $this-\>Form-\>input('user\_password') ?\>

```
    </fieldset>
<?= $this->Form->button(__('login')); ?>
<?= $this->Form->end() ?>

```

Any Help

---

<div class="post-metadata">

**Author:** ![rrd](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/rrd/32/113_2.png) [@rrd](https://discourse.cakephp.org/u/rrd)\
**Post date:** [September 22, 2016, 9:00am UTC](https://discourse.cakephp.org/t/cakephp-3-auth-not-working/1209/2 "2016-09-22T09:00:00Z")

</div>

If you ask something post the error message. without that we do not have enough information.

Is Auth component loaded somewhere?
