From f78f2a5e8ce9a229109d021613d45c61ab1595a1 Mon Sep 17 00:00:00 2001 From: Thijs Kinkhorst <thijs@kinkhorst.com> Date: Wed, 12 Feb 2020 14:47:08 +0000 Subject: [PATCH] Set autocomplete=username attribute on username field. In the modern template also clean up HTML a bit. --- modules/core/templates/loginuserpass.tpl.php | 2 +- modules/core/templates/loginuserpass.twig | 14 +++++++------- templates/login-ldapmulti.php | 2 +- templates/login.php | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/core/templates/loginuserpass.tpl.php b/modules/core/templates/loginuserpass.tpl.php index 7dbeab9ad..30c8db549 100644 --- a/modules/core/templates/loginuserpass.tpl.php +++ b/modules/core/templates/loginuserpass.tpl.php @@ -54,7 +54,7 @@ if ($this->data['errorcode'] !== null) { <td><label for="username"><?php echo $this->t('{login:username}'); ?></label></td> <td> <input id="username" <?php echo ($this->data['forceUsername']) ? 'disabled="disabled"' : ''; ?> - type="text" name="username"<?php echo $this->data['forceUsername'] ? '' : ' tabindex="1"'; ?> + type="text" name="username"<?php echo $this->data['forceUsername'] ? '' : ' autocomplete="username" tabindex="1"'; ?> value="<?php echo htmlspecialchars($this->data['username']); ?>" /> </td> <?php diff --git a/modules/core/templates/loginuserpass.twig b/modules/core/templates/loginuserpass.twig index 5471f5f12..3eb6aaf34 100644 --- a/modules/core/templates/loginuserpass.twig +++ b/modules/core/templates/loginuserpass.twig @@ -46,15 +46,15 @@ <div class="pure-control-group"> <label for="username">{{ 'Username'|trans }}</label> - <input id="username" {{ forceUsername ? 'disabled="disabled"' }} placeholder="{{ username }}" type="text" name="username" class="edge" - {%- if not forceUsername %} tabindex="1" value="{{ username }}" {% endif %} - {%- if not forceUsername and not username %} autofocus {% endif %} /> + <input id="username" {{ forceUsername ? 'disabled' }} placeholder="{{ username }}" type="text" name="username" class="edge" + {%- if not forceUsername %} tabindex="1" value="{{ username }}" autocomplete="username" {% endif %} + {%- if not forceUsername and not username %} autofocus {% endif %} > {% if rememberUsernameEnabled and not forceUsername -%} </div> <div class="pure-controls pure-form-message"> <label for="remember_username" class="pure-checkbox"> <input id="remember_username" type="checkbox" tabindex="4" - {{ rememberUsernameChecked ? 'checked="checked"' }} name="remember_username" value="Yes"/> + {{ rememberUsernameChecked ? 'checked' }} name="remember_username" value="Yes"> <small>{{ 'Remember my username'|trans }}</small> </label> {%- endif %} @@ -70,7 +70,7 @@ <div class="pure-controls pure-form-message"> <label for="remember_me" class="pure-checkbox"> <input id="remember_me" type="checkbox" tabindex="5" - {{ rememberMeChecked ? 'checked="checked"' }} name="remember_me" value="Yes"/> + {{ rememberMeChecked ? 'checked="checked"' }} name="remember_me" value="Yes"> <small>{{ 'Remember me'|trans }}</small> </label> {%- endif %} @@ -97,7 +97,7 @@ <div class="pure-controls pure-form-message"> <label for="remember_organization" class="pure-checkbox"> <input type="checkbox" id="remember_organization" tabindex="5" name="remember_organization" value="Yes" - {{ rememberOrganizationChecked ? 'checked="checked"' }} /> + {{ rememberOrganizationChecked ? 'checked="checked"' }} > <small>{{ 'Remember my organization'|trans }}</small> </label> </div> @@ -109,7 +109,7 @@ <br><br> {%- for name, value in stateparams %} - <input type="hidden" name="{{ name }}" value="{{ value }}"/> + <input type="hidden" name="{{ name }}" value="{{ value }}"> {%- endfor %} <button class="pure-button pure-button-red pure-input-1-2 pure-input-sm-1-1 right" id="submit_button" diff --git a/templates/login-ldapmulti.php b/templates/login-ldapmulti.php index b4cf136df..64159298d 100644 --- a/templates/login-ldapmulti.php +++ b/templates/login-ldapmulti.php @@ -24,7 +24,7 @@ if (isset($this->data['error'])) { <tr> <td rowspan="3"><img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-authentication.48x48.png" id="loginicon" alt="" /></td> <td style="padding: .3em;"><?php echo $this->t('username'); ?></td> - <td><input type="text" tabindex="1" name="username" + <td><input type="text" tabindex="1" name="username" autocomplete="username" <?php if (isset($this->data['username'])) { echo 'value="'.htmlspecialchars($this->data['username']).'"'; diff --git a/templates/login.php b/templates/login.php index fb1d7b951..04502944d 100644 --- a/templates/login.php +++ b/templates/login.php @@ -28,7 +28,7 @@ if (array_key_exists('admin', $this->data)) { echo '<strong style="font-size: medium">Administrator</strong>'; } else { - echo '<input type="text" id="username" tabindex="1" name="username" '; + echo '<input type="text" id="username" tabindex="1" name="username" autocomplete="username" '; if (isset($this->data['username'])) { echo 'value="'.htmlspecialchars($this->data['username']).'"'; } -- GitLab