I have successfully made the login system with the table and fields that come by default in cakephp, I have decided to change the table and fields to login and now does not log in.
Logs / Login.ctp file:
<div class="large-4 columns" style="margin-left: 15px; margin-top: 0px;">
<div class="row">
<div class="users form">
<?php echo $this->Session->flash('auth'); ?>
<?php echo $this->Form->create('Registos'); ?>
<fieldset>
<?php
echo $this->Form->input('email');
echo $this->Form->input('password');
?>
</fieldset>
<?php
echo $this->Form->submit(
'Login', array('class' => 'button')); ?>
</div>
</div>
AppController file:
class AppController extends Controller {
public $components = array(
'Session',
'Auth' => array(
'authenticate' => array(
'Form' => array(
'userModel' => 'Registo',
'fields' => array(
'username' => 'email',
'password' => 'password'
)
)
),
'loginAction' => array('controller' => 'registos', 'action' => 'login'),
'loginRedirect' => array('controller' => 'anuncios', 'action' => 'index')
)
);
function beforeFilter() {
$this->Auth->allow();
}
}
Action Login:
public function login() {
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());
} else {
//$this->Session->setFlash(__('Invalid username or password, try again'));
}
}
My table in the database is called users and has the email and the password.
It arrives to action login with the values of the correct email and password, but it does not login, I suspect that it is not checking in the right table, but I do not understand why.