/** * @param $validator * @param string $attribute * @return bool */ public function validate($validator, $attribute) { $value = $validator->getValue($attribute); $usr = Login::getCurrentUser(); if (!$usr['id']) { $validator->appendMessage(new Validation\Message('ERR_USER_NOT_LOGIN', $attribute)); return false; } /** * @var $usr User */ $usr = User::findFirst('id = ' . $usr['id']); if (!Login::passwordVerify($value, $usr->password)) { $message = $this->getOption('message'); if (!$message) { //$message = 'The old password provided is incorrect.'; $message = 'ERR_USER_OLD_PASSWORD_NOT_MATCH'; } $validator->appendMessage(new Validation\Message($message, $attribute, null, null)); return false; } return true; }