From c15ee4ba159b4a2c01109e3dcbbcdf030c867aa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Noack?= <noack@data-quest.de> Date: Fri, 2 Feb 2024 09:55:44 +0000 Subject: [PATCH] Resolve "autocomplete im Registrierungsformular" Closes #3705 Merge request studip/studip!2577 --- app/controllers/registration.php | 13 ++++++++++++- templates/forms/datalist_input.php | 13 +++++++++---- templates/forms/radio_input.php | 3 ++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/app/controllers/registration.php b/app/controllers/registration.php index de866836778..378918bbabe 100644 --- a/app/controllers/registration.php +++ b/app/controllers/registration.php @@ -16,7 +16,9 @@ class RegistrationController extends AuthenticatedController public function index_action() { $new_user = new User(); - + $new_user->perms = 'user'; + $new_user->auth_plugin = 'standard'; + $new_user->preferred_language = $_SESSION['_language'] ?? Config::get()->DEFAULT_LANGUAGE; $this->registrationform = Form::fromSORM( $new_user, [ @@ -26,6 +28,7 @@ class RegistrationController extends AuthenticatedController 'label' => _('Benutzername'), 'required' => true, 'maxlength' => '63', + 'attributes' => ['autocomplete' => 'off'], 'validate' => function ($value, $input) { if (!preg_match(Config::get()->USERNAME_REGULAR_EXPRESSION, $value)) { return Config::get()->getMetadata('USERNAME_REGULAR_EXPRESSION')['comment'] ?: @@ -46,6 +49,7 @@ class RegistrationController extends AuthenticatedController 'required' => true, 'maxlength' => '31', 'minlength' => '8', + 'attributes' => ['autocomplete' => 'new-password'], 'mapper' => function($value) { $hasher = UserManagement::getPwdHasher(); return $hasher->HashPassword($value); @@ -57,6 +61,7 @@ class RegistrationController extends AuthenticatedController 'required' => true, 'maxlength' => '31', 'minlength' => '8', + 'attributes' => ['autocomplete' => 'new-password'], ':pattern' => "password.replace(/[.*+?^\${}()|[\\]\\\\]/g, '\\\\$&')", //mask special chars 'data-validation_requirement' => _('Passwörter stimmen nicht überein.'), 'store' => function() {} @@ -64,23 +69,28 @@ class RegistrationController extends AuthenticatedController 'title_front' => [ 'label' => _('Titel'), 'type' => 'datalist', + 'attributes' => ['autocomplete' => 'honorific-prefix'], 'options' => $GLOBALS['TITLE_FRONT_TEMPLATE'] ], 'title_rear' => [ 'label' => _('Titel nachgestellt'), 'type' => 'datalist', + 'attributes' => ['autocomplete' => 'honorific-suffix'], 'options' => $GLOBALS['TITLE_REAR_TEMPLATE'], ], 'vorname' => [ 'label' => _('Vorname'), + 'attributes' => ['autocomplete' => 'given-name'], 'required' => true ], 'nachname' => [ 'label' => _('Nachname'), + 'attributes' => ['autocomplete' => 'family-name'], 'required' => true ], 'geschlecht' => [ 'name' => 'geschlecht', + 'value' => 0, 'label' => _('Geschlecht'), 'type' => 'radio', 'orientation' => 'horizontal', @@ -94,6 +104,7 @@ class RegistrationController extends AuthenticatedController 'email' => [ 'label' => _('E-Mail'), 'required' => true, + 'attributes' => ['autocomplete' => 'email'], 'validate' => function ($value, $input) { $user = User::findOneByEmail($value); $context = $input->getContextObject(); diff --git a/templates/forms/datalist_input.php b/templates/forms/datalist_input.php index 7958c332875..bf18732f208 100644 --- a/templates/forms/datalist_input.php +++ b/templates/forms/datalist_input.php @@ -6,10 +6,15 @@ <? if ($this->required) : ?> <span class="asterisk" title="<?= _('Dies ist ein Pflichtfeld') ?>" aria-hidden="true">*</span> <? endif ?> - - <input type="text" list="<?= $this->title ?>" id="" v-model="<?= htmlReady($this->name) ?>" <?= $this->required ? 'required aria-required="true"' : '' ?> /> - - <datalist class="" id="<?= $this->title ?>" <?= $attributes ?>> + <input type="text" + list="<?= htmlReady($this->title) ?>" + v-model="<?= htmlReady($this->name) ?>" + name="<?= htmlReady($this->name) ?>" + value="<?= htmlReady($this->value) ?>" + id="<?= htmlReady($id) ?>" + <?= $this->required ? 'required aria-required="true"' : '' ?> + <?= $attributes ?>> + <datalist class="" id="<?= htmlReady($this->title) ?>"> <? foreach ($options as $key => $option) : ?> <option value="<?= htmlReady($option) ?>"<?= ($option == $value ? " selected" : "") ?>> </option> diff --git a/templates/forms/radio_input.php b/templates/forms/radio_input.php index 37170c99e49..da110d1f830 100644 --- a/templates/forms/radio_input.php +++ b/templates/forms/radio_input.php @@ -1,5 +1,5 @@ <div class="formpart"> - <section <?= $this->orientation == 'horizontal' ? 'class="hgroup"' : '' ?> for="<?= $id ?>"> + <section <?= $this->orientation == 'horizontal' ? 'class="hgroup"' : '' ?> id="<?= htmlReady($id) ?>"> <span class="textlabel"> <?= htmlReady($this->title) ?> </span> @@ -7,6 +7,7 @@ <? foreach ($options as $key => $option) : ?> <label class="" <?= $attributes ?>> <input type="radio" + name="<?= htmlReady($this->name) ?>" v-model="<?= htmlReady($this->name) ?>" value="<?= htmlReady($key) ?>" <?= $key == $value ? 'checked' : '' ?>> <?= htmlReady($option) ?> -- GitLab