Skip to content
Snippets Groups Projects
Commit c15ee4ba authored by André Noack's avatar André Noack
Browse files

Resolve "autocomplete im Registrierungsformular"

Closes #3705

Merge request studip/studip!2577
parent 6b7b04e0
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,9 @@ class RegistrationController extends AuthenticatedController ...@@ -16,7 +16,9 @@ class RegistrationController extends AuthenticatedController
public function index_action() public function index_action()
{ {
$new_user = new User(); $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( $this->registrationform = Form::fromSORM(
$new_user, $new_user,
[ [
...@@ -26,6 +28,7 @@ class RegistrationController extends AuthenticatedController ...@@ -26,6 +28,7 @@ class RegistrationController extends AuthenticatedController
'label' => _('Benutzername'), 'label' => _('Benutzername'),
'required' => true, 'required' => true,
'maxlength' => '63', 'maxlength' => '63',
'attributes' => ['autocomplete' => 'off'],
'validate' => function ($value, $input) { 'validate' => function ($value, $input) {
if (!preg_match(Config::get()->USERNAME_REGULAR_EXPRESSION, $value)) { if (!preg_match(Config::get()->USERNAME_REGULAR_EXPRESSION, $value)) {
return Config::get()->getMetadata('USERNAME_REGULAR_EXPRESSION')['comment'] ?: return Config::get()->getMetadata('USERNAME_REGULAR_EXPRESSION')['comment'] ?:
...@@ -46,6 +49,7 @@ class RegistrationController extends AuthenticatedController ...@@ -46,6 +49,7 @@ class RegistrationController extends AuthenticatedController
'required' => true, 'required' => true,
'maxlength' => '31', 'maxlength' => '31',
'minlength' => '8', 'minlength' => '8',
'attributes' => ['autocomplete' => 'new-password'],
'mapper' => function($value) { 'mapper' => function($value) {
$hasher = UserManagement::getPwdHasher(); $hasher = UserManagement::getPwdHasher();
return $hasher->HashPassword($value); return $hasher->HashPassword($value);
...@@ -57,6 +61,7 @@ class RegistrationController extends AuthenticatedController ...@@ -57,6 +61,7 @@ class RegistrationController extends AuthenticatedController
'required' => true, 'required' => true,
'maxlength' => '31', 'maxlength' => '31',
'minlength' => '8', 'minlength' => '8',
'attributes' => ['autocomplete' => 'new-password'],
':pattern' => "password.replace(/[.*+?^\${}()|[\\]\\\\]/g, '\\\\$&')", //mask special chars ':pattern' => "password.replace(/[.*+?^\${}()|[\\]\\\\]/g, '\\\\$&')", //mask special chars
'data-validation_requirement' => _('Passwörter stimmen nicht überein.'), 'data-validation_requirement' => _('Passwörter stimmen nicht überein.'),
'store' => function() {} 'store' => function() {}
...@@ -64,23 +69,28 @@ class RegistrationController extends AuthenticatedController ...@@ -64,23 +69,28 @@ class RegistrationController extends AuthenticatedController
'title_front' => [ 'title_front' => [
'label' => _('Titel'), 'label' => _('Titel'),
'type' => 'datalist', 'type' => 'datalist',
'attributes' => ['autocomplete' => 'honorific-prefix'],
'options' => $GLOBALS['TITLE_FRONT_TEMPLATE'] 'options' => $GLOBALS['TITLE_FRONT_TEMPLATE']
], ],
'title_rear' => [ 'title_rear' => [
'label' => _('Titel nachgestellt'), 'label' => _('Titel nachgestellt'),
'type' => 'datalist', 'type' => 'datalist',
'attributes' => ['autocomplete' => 'honorific-suffix'],
'options' => $GLOBALS['TITLE_REAR_TEMPLATE'], 'options' => $GLOBALS['TITLE_REAR_TEMPLATE'],
], ],
'vorname' => [ 'vorname' => [
'label' => _('Vorname'), 'label' => _('Vorname'),
'attributes' => ['autocomplete' => 'given-name'],
'required' => true 'required' => true
], ],
'nachname' => [ 'nachname' => [
'label' => _('Nachname'), 'label' => _('Nachname'),
'attributes' => ['autocomplete' => 'family-name'],
'required' => true 'required' => true
], ],
'geschlecht' => [ 'geschlecht' => [
'name' => 'geschlecht', 'name' => 'geschlecht',
'value' => 0,
'label' => _('Geschlecht'), 'label' => _('Geschlecht'),
'type' => 'radio', 'type' => 'radio',
'orientation' => 'horizontal', 'orientation' => 'horizontal',
...@@ -94,6 +104,7 @@ class RegistrationController extends AuthenticatedController ...@@ -94,6 +104,7 @@ class RegistrationController extends AuthenticatedController
'email' => [ 'email' => [
'label' => _('E-Mail'), 'label' => _('E-Mail'),
'required' => true, 'required' => true,
'attributes' => ['autocomplete' => 'email'],
'validate' => function ($value, $input) { 'validate' => function ($value, $input) {
$user = User::findOneByEmail($value); $user = User::findOneByEmail($value);
$context = $input->getContextObject(); $context = $input->getContextObject();
......
...@@ -6,10 +6,15 @@ ...@@ -6,10 +6,15 @@
<? if ($this->required) : ?> <? if ($this->required) : ?>
<span class="asterisk" title="<?= _('Dies ist ein Pflichtfeld') ?>" aria-hidden="true">*</span> <span class="asterisk" title="<?= _('Dies ist ein Pflichtfeld') ?>" aria-hidden="true">*</span>
<? endif ?> <? endif ?>
<input type="text"
<input type="text" list="<?= $this->title ?>" id="" v-model="<?= htmlReady($this->name) ?>" <?= $this->required ? 'required aria-required="true"' : '' ?> /> list="<?= htmlReady($this->title) ?>"
v-model="<?= htmlReady($this->name) ?>"
<datalist class="" id="<?= $this->title ?>" <?= $attributes ?>> 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) : ?> <? foreach ($options as $key => $option) : ?>
<option value="<?= htmlReady($option) ?>"<?= ($option == $value ? " selected" : "") ?>> <option value="<?= htmlReady($option) ?>"<?= ($option == $value ? " selected" : "") ?>>
</option> </option>
......
<div class="formpart"> <div class="formpart">
<section <?= $this->orientation == 'horizontal' ? 'class="hgroup"' : '' ?> for="<?= $id ?>"> <section <?= $this->orientation == 'horizontal' ? 'class="hgroup"' : '' ?> id="<?= htmlReady($id) ?>">
<span class="textlabel"> <span class="textlabel">
<?= htmlReady($this->title) ?> <?= htmlReady($this->title) ?>
</span> </span>
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<? foreach ($options as $key => $option) : ?> <? foreach ($options as $key => $option) : ?>
<label class="" <?= $attributes ?>> <label class="" <?= $attributes ?>>
<input type="radio" <input type="radio"
name="<?= htmlReady($this->name) ?>"
v-model="<?= htmlReady($this->name) ?>" v-model="<?= htmlReady($this->name) ?>"
value="<?= htmlReady($key) ?>" <?= $key == $value ? 'checked' : '' ?>> value="<?= htmlReady($key) ?>" <?= $key == $value ? 'checked' : '' ?>>
<?= htmlReady($option) ?> <?= htmlReady($option) ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment