2
I started using the cakephp recently and created a login for my project. The login works perfectly, but is always displaying an invalid user or password message.
What can I do to display this message ONLY when the login is invalid?
Function of login:
public function login() {
        if ($this->Auth->login()) {
            if($this->Auth->user('role') === 'paciente') {
                $this->redirect(array('controller' => 'pacientes', 'action' => 'index'));
            }
            elseif($this->Auth->user('role') === 'medico') {
                $this->redirect(array('controller' => 'medicos', 'action' => 'index'));
            }
        } else {
            $this->Session->setFlash(__('Invalid username or password, try again'));
        }
    }