Guys, Please I need your help
I have a login page that includes nis and password as verification data.
this is my data in my database
I want to create a login page without using a password hasher
And this is my code
AppController.php
public function initialize(): void { parent::initialize(); $this->loadComponent('RequestHandler'); $this->loadComponent('Flash'); $this->loadComponent('Auth', [ 'authenticate' => [ 'Form' => [ 'fields' => [ 'nis' => 'nis', 'password' => 'password' ] ] ], 'loginAction' => [ 'controller' => 'Users', 'action' => 'login' ], 'unauthorizedRedirect' => $this->referer() ]); $this->Auth->allow(['display']);
UsersController.php
public function login(){ // $this->autoRender = false; if ($this->request->is('post')) { # code... $user = $this->Auth->identify(); debug($user); die(); if ($user) { # code... $this->Auth->setUser($user); return $this->redirect($this->Auth->redirectUrl()); } $this->Flash->error('Your username or password is Incorrect'); } }
templates/users/login.php
<?= $this->Form->create(null, ['style' => 'padding:20px'])?> <?= $this->Form->control('nis', ['style' => 'opacity: 0.85'])?> <?= $this->Form->control('password', ['style' => 'opacity: 0.85'])?> <?= $this->Form->button('LOGIN', ['class' => 'btn btn-block btn-instagram btn-flat', 'style' => 'height:50px;opacity: 0.85;'])?> <?= $this->Form->end()?>
when I debug the login function in UsersController
it showing false
APP/Controller\UsersController.php (line 131)
false
Anyone can help me
thank you