I've a user manager in my project. When i'm adding user all validations must be called but according to my requirement when i'm email & password from user to login then i want that isunique validation for email address not be called.
UserController.php
public function login() {
$this->layout = 'login';
if ($this->request->is('post')) {
/** these conditions are used to call validations forcefully **/
if (!empty($this->request->data)) {
$this->User->set($this->request->data);
if($this->User->validates()) {
}
} else {
$errors = $this->User->invalidFields();
}
if ($this->Auth->login()) {
return $this->redirect($this->Auth->redirectUrl());
} else {
//$errors = "Invalid email or password, try again";
$this->Session->setFlash(__('Invalid email or password, try again'));
}
}
}
User.php
public $validate = array(
'email' => array(
'required' => array(
'rule' => 'notEmpty',
'message' => 'A email is required.'
),
'email' => array(
'rule' => array('email', true),
'message' => 'Please fill a valid email address.'
),
'isUnique' => array(
'rule' => array('isUnique'),
'message' => 'This email id already exist.'
)
),
'password' => array(
'rule' => 'notEmpty',
'message' => 'Please enter password.'
)
);
But when i login it shows "This email id already exist." message for right email address but i want to skip this validation if email id is exist in database.