1
I had already successfully logged in with the default table and fields in cakephp, I decided to change the table and fields for login and now do not log in.
File Logs/login.ctp:
<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 email and password.
It comes to login action with the right email and password values, but does not login, I suspect it is not checking in the right table, but I do not understand why.
You specified the name of the table in the model?
– bfavaretto
I think you’re calling the wrong model in your view
– Erlon Charles