Hello everyone I have tried the basic auth login and its working fine but when used with admin prefix the
$this->Auth->login() is returning false.
here are my code snippets,
In Model i have added,
public function beforeSave($options = array()) {
if (isset($this->data[$this->alias]['password'])) {
$this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
}
return true;
}
In AppController I added the following code,
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('controller' => 'users', 'action' => 'index', 'admin' => true),
'logoutRedirect' => array('controller' => 'users', 'action' => 'login', 'admin' => true)
)
);
In UsersController my admin login is as follows,
public function admin_login() {
if ($this->request->is('post')) {
//$this->request->data['User']['password'] = AuthComponent::password($this->request->data['User']['password']);
debug($this->request->data['User']['password']);
debug($this->Auth->login());
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash(__('Invalid username or password, try again'));
}
}
}
In the above,
debug($this->request->data['User']['password']) is returning the correct password but
debug($this->Auth->login()) is returning false.
I am not able to figure out whats the reason it is returning false, is there any changes that needs to be done for admin routing.