Skip to content

Commit

Permalink
Merge pull request #20347 from demeritcowboy/pass-compare
Browse files Browse the repository at this point in the history
dev/core#2613 - Replace deprecated function in useradd task
  • Loading branch information
seamuslee001 authored May 19, 2021
2 parents fd8f3fc + 96000ce commit bc360ba
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions CRM/Contact/Form/Task/Useradd.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ public function buildQuickForm() {
$this->add('password', 'cms_pass', ts('Password'), ['class' => 'huge']);
$this->add('password', 'cms_confirm_pass', ts('Confirm Password'), ['class' => 'huge']);
$this->addRule('cms_pass', ts('Password is required'), 'required');
$this->addRule([
'cms_pass',
'cms_confirm_pass',
], ts('Password mismatch'), 'compare');
$this->addFormRule(['CRM_Contact_Form_Task_Useradd', 'passwordMatch']);
}

$this->add('text', 'email', ts('Email'), ['class' => 'huge'])->freeze();
Expand Down Expand Up @@ -140,4 +137,18 @@ public static function usernameRule($params) {
return empty($errors) ? TRUE : $errors;
}

/**
* Validation Rule.
*
* @param array $params
*
* @return array|bool
*/
public static function passwordMatch($params) {
if ($params['cms_pass'] !== $params['cms_confirm_pass']) {
return ['cms_pass' => ts('Password mismatch')];
}
return TRUE;
}

}

0 comments on commit bc360ba

Please sign in to comment.