fix: [users:add] Decoupled password required and visibility

pull/93/head
Sami Mokaddem 2022-03-01 13:59:10 +01:00
parent b91f4b5d01
commit 3d0fdeba81
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 6 additions and 2 deletions

View File

@ -1,12 +1,16 @@
<?php
use Cake\Core\Configure;
$passwordRequired = false;
$showPasswordField = false;
if ($this->request->getParam('action') === 'add') {
$dropdownData['individual'] = ['new' => __('New individual')] + $dropdownData['individual'];
if (!Configure::check('password_auth.enabled') || Configure::read('password_auth.enabled')) {
$passwordRequired = 'required';
}
}
if (!Configure::check('password_auth.enabled') || Configure::read('password_auth.enabled')) {
$showPasswordField = true;
}
echo $this->element('genericElements/Form/genericForm', [
'data' => [
'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,
'autocomplete' => 'new-password',
'value' => '',
'requirements' => (bool)$passwordRequired
'requirements' => $showPasswordField,
],
[
'field' => 'confirm_password',
@ -70,7 +74,7 @@
'type' => 'password',
'required' => $passwordRequired,
'autocomplete' => 'off',
'requirements' => (bool)$passwordRequired
'requirements' => $showPasswordField,
],
[
'field' => 'role_id',