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"; . '" method="post">' . "\n";
$html .= form_csrf(); $html .= form_csrf();
$html .= '<table>' . "\n"; $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>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"></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 .= '</table>' . "\n" . '<br />' . "\n";
$html .= '<input type="submit" value="Speichern" class="btn btn-primary">' . "\n"; $html .= '<input type="submit" value="Speichern" class="btn btn-primary">' . "\n";

View File

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

View File

@ -294,18 +294,20 @@ function form_file($name, $label)
* *
* @param string $name * @param string $name
* @param string $label * @param string $label
* @param string $autocomplete
* @param bool $disabled * @param bool $disabled
* @return string * @return string
*/ */
function form_password($name, $label, $disabled = false) function form_password($name, $label, $autocomplete, $disabled = false)
{ {
$disabled = $disabled ? ' disabled="disabled"' : ''; $disabled = $disabled ? ' disabled="disabled"' : '';
return form_element( return form_element(
$label, $label,
sprintf( 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, $name,
config('min_password_length'), config('min_password_length'),
$autocomplete,
$disabled $disabled
), ),
'form_' . $name 'form_' . $name

View File

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

View File

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

View File

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

View File

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