Skip to content

Commit

Permalink
CIVICRM-1737 Create User Record now hides the Password field and uses…
Browse files Browse the repository at this point in the history
… the check isUserRegistrationPermitted - which prevents Administrators from setting passwords for new Users
  • Loading branch information
agileware-justin committed May 18, 2021
1 parent 664c087 commit 0c15d5a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions CRM/Contact/Form/Task/Useradd.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,22 @@ public function buildQuickForm() {
$element = $this->add('text', 'name', ts('Full Name'), ['class' => 'huge']);
$element->freeze();
$this->add('text', 'cms_name', ts('Username'), ['class' => 'huge']);
$this->addRule('cms_name', 'Username is required', 'required');
$this->addRule('cms_name', ts('Username is required'), 'required');

if (!$config->userSystem->isUserRegistrationPermitted()) {
// For WordPress only, comply with how WordPress sets passwords via magic link
// For other CMS, output the password fields
if ($config->userFramework !== 'WordPress' || ($config->userFramework === 'WordPress' && !$config->userSystem->isUserRegistrationPermitted())) {
$this->add('password', 'cms_pass', ts('Password'), ['class' => 'huge']);
$this->add('password', 'cms_confirm_pass', ts('Confirm Password'), ['class' => 'huge']);
$this->addRule('cms_pass', 'Password is required', 'required');
$this->addRule(['cms_pass', 'cms_confirm_pass'], 'ERROR: Password mismatch', 'compare');
$this->addRule('cms_pass', ts('Password is required'), 'required');
$this->addRule([
'cms_pass',
'cms_confirm_pass',
], ts('Password mismatch'), 'compare');
}

$this->add('text', 'email', ts('Email:'), ['class' => 'huge'])->freeze();
$this->addRule('email', 'Email is required', 'required');
$this->add('text', 'email', ts('Email'), ['class' => 'huge'])->freeze();
$this->addRule('email', ts('Email is required'), 'required');
$this->add('hidden', 'contactID');

//add a rule to check username uniqueness
Expand Down

0 comments on commit 0c15d5a

Please sign in to comment.