set autocomplete attribute for password inputs

This commit is contained in:
Thomas Rupprecht 2022-12-10 23:05:49 +01:00 committed by Michael Weimann
parent ce0ac6f823
commit f12f8a1b3b
7 changed files with 15 additions and 12 deletions

View File

@ -119,8 +119,8 @@ function admin_user()
. '" method="post">' . "\n";
$html .= form_csrf();
$html .= '<table>' . "\n";
$html .= ' <tr><td>Passwort</td><td>' . '<input type="password" size="40" name="new_pw" value="" class="form-control"></td></tr>' . "\n";
$html .= ' <tr><td>Wiederholung</td><td>' . '<input type="password" size="40" name="new_pw2" value="" class="form-control"></td></tr>' . "\n";
$html .= ' <tr><td>Passwort</td><td>' . '<input type="password" size="40" name="new_pw" value="" class="form-control" autocomplete="new-password"></td></tr>' . "\n";
$html .= ' <tr><td>Wiederholung</td><td>' . '<input type="password" size="40" name="new_pw2" value="" class="form-control" autocomplete="new-password"></td></tr>' . "\n";
$html .= '</table>' . "\n" . '<br />' . "\n";
$html .= '<input type="submit" value="Speichern" class="btn btn-primary">' . "\n";

View File

@ -466,7 +466,7 @@ function guest_register()
div('row', [
$enable_password ? div('col', [
form_password('password', __('Password') . ' ' . entry_required())
form_password('password', __('Password') . ' ' . entry_required(), 'new-password')
]) : '',
$enable_planned_arrival ? div('col', [
@ -482,7 +482,7 @@ function guest_register()
div('row', [
$enable_password ? div('col', [
form_password('password2', __('Confirm password') . ' ' . entry_required())
form_password('password2', __('Confirm password') . ' ' . entry_required(), 'new-password')
]) : '',
div('col', [

View File

@ -294,18 +294,20 @@ function form_file($name, $label)
*
* @param string $name
* @param string $label
* @param string $autocomplete
* @param bool $disabled
* @return string
*/
function form_password($name, $label, $disabled = false)
function form_password($name, $label, $autocomplete, $disabled = false)
{
$disabled = $disabled ? ' disabled="disabled"' : '';
return form_element(
$label,
sprintf(
'<input class="form-control" id="form_%1$s" type="password" name="%1$s" minlength="%2$s" value=""%3$s/>',
'<input class="form-control" id="form_%1$s" type="password" name="%1$s" minlength="%2$s" value="" autocomplete="%3$s"%4$s/>',
$name,
config('min_password_length'),
$autocomplete,
$disabled
),
'form_' . $name

View File

@ -27,7 +27,7 @@ function User_delete_view($user)
true
),
form([
form_password('password', __('Your password')),
form_password('password', __('Your password'), 'current-password'),
form_submit('submit', __('Delete'))
])
]);

View File

@ -21,6 +21,7 @@
{%- if opt.min is defined %} min="{{ opt.min }}"{% endif %}
{%- if opt.max is defined %} max="{{ opt.max }}"{% endif %}
{%- if opt.step is defined %} step="{{ opt.step }}"{% endif %}
{%- if opt.autocomplete is defined %} autocomplete="{{ opt.autocomplete }}"{% endif %}
{%- if opt.required|default(false) %}
required
{%- endif -%}

View File

@ -58,8 +58,8 @@
<i class="bi bi-key"></i>
</span>
<input
class="form-control" id="form_password"
type="password" name="password" value="" placeholder="{{ __('Password') }}"
class="form-control" id="form_password" type="password"
name="password" value="" placeholder="{{ __('Password') }}" autocomplete="current-password"
>
</div>
</div>

View File

@ -17,20 +17,20 @@
'password',
__('settings.password.password'),
'password',
{'required': true}
{'required': true, 'autocomplete': 'current-password'}
) }}
{% endif %}
{{ f.input(
'new_password',
__('settings.password.new_password'),
'password',
{'min_length': min_length, 'required': true}
{'min_length': min_length, 'required': true, 'autocomplete': 'new-password'}
) }}
{{ f.input(
'new_password2',
__('settings.password.new_password2'),
'password',
{'min_length': min_length, 'required': true}
{'min_length': min_length, 'required': true, 'autocomplete': 'new-password'}
) }}
{{ f.submit(__('form.save')) }}
</div>