/** * Returns the JavaScript needed for performing client-side validation. * @param CModel $object the data object being validated * @param string $attribute the name of the attribute to be validated. * @return string the client-side validation script. * @see CActiveForm::enableClientValidation */ public function clientValidateAttribute($object, $attribute) { $phis = new PasswordHistory(); $passes = $phis->getHistory(Yii::app()->user->id); $condition = "1==2"; foreach ($passes as $pass) { $value = $object->{$attribute}; if (PasswordHelper::verifyPassword($value, $pass->password)) { $condition = "1==1"; $this->addError($object, $attribute, 'You can not use a password which you have already used!'); break; } } return "\n\tif(" . $condition . ") {\n\t\tmessages.push(" . CJSON::encode('your password is too weak, you fool!') . ");\n\t}\n\t"; }