Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create User Record now hides the Password field and uses the check isUserRegistrationPermitted - which prevents Administrators from setting passwords for new Users #20274

Merged
merged 1 commit into from
May 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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