fix: [users:add] Decoupled password required and visibility
parent
b91f4b5d01
commit
3d0fdeba81
|
@ -1,12 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
use Cake\Core\Configure;
|
use Cake\Core\Configure;
|
||||||
$passwordRequired = false;
|
$passwordRequired = false;
|
||||||
|
$showPasswordField = false;
|
||||||
if ($this->request->getParam('action') === 'add') {
|
if ($this->request->getParam('action') === 'add') {
|
||||||
$dropdownData['individual'] = ['new' => __('New individual')] + $dropdownData['individual'];
|
$dropdownData['individual'] = ['new' => __('New individual')] + $dropdownData['individual'];
|
||||||
if (!Configure::check('password_auth.enabled') || Configure::read('password_auth.enabled')) {
|
if (!Configure::check('password_auth.enabled') || Configure::read('password_auth.enabled')) {
|
||||||
$passwordRequired = 'required';
|
$passwordRequired = 'required';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!Configure::check('password_auth.enabled') || Configure::read('password_auth.enabled')) {
|
||||||
|
$showPasswordField = true;
|
||||||
|
}
|
||||||
echo $this->element('genericElements/Form/genericForm', [
|
echo $this->element('genericElements/Form/genericForm', [
|
||||||
'data' => [
|
'data' => [
|
||||||
'description' => __('Roles define global rules for a set of users, including first and foremost access controls to certain functionalities.'),
|
'description' => __('Roles define global rules for a set of users, including first and foremost access controls to certain functionalities.'),
|
||||||
|
@ -62,7 +66,7 @@
|
||||||
'required' => $passwordRequired,
|
'required' => $passwordRequired,
|
||||||
'autocomplete' => 'new-password',
|
'autocomplete' => 'new-password',
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'requirements' => (bool)$passwordRequired
|
'requirements' => $showPasswordField,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'field' => 'confirm_password',
|
'field' => 'confirm_password',
|
||||||
|
@ -70,7 +74,7 @@
|
||||||
'type' => 'password',
|
'type' => 'password',
|
||||||
'required' => $passwordRequired,
|
'required' => $passwordRequired,
|
||||||
'autocomplete' => 'off',
|
'autocomplete' => 'off',
|
||||||
'requirements' => (bool)$passwordRequired
|
'requirements' => $showPasswordField,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'field' => 'role_id',
|
'field' => 'role_id',
|
||||||
|
|
Loading…
Reference in New Issue