I have done simple login in Cakephp using authcomponent, it really works fine, how can I do login using ajax?
I have use code for simple login that are given below:
if ($this->request->is('post'))
{
if ($this->Auth->login())
{
if ($this->Auth->user('role') === 'admin')
{
$this->redirect(array('admin' => false,'controller' => 'users','action' => 'index'));
}
}
}
Your ajax code should be like this :
And in your login method should be like this:
For Blowfish password hash, In your AppController:
And in AppModel: