From f12f8a1b3b646367826b51452665ce9bf0f19d67 Mon Sep 17 00:00:00 2001 From: Thomas Rupprecht Date: Sat, 10 Dec 2022 23:05:49 +0100 Subject: [PATCH] set autocomplete attribute for password inputs --- includes/pages/admin_user.php | 4 ++-- includes/pages/guest_login.php | 4 ++-- includes/sys_form.php | 6 ++++-- includes/view/User_view.php | 2 +- resources/views/macros/form.twig | 1 + resources/views/pages/login.twig | 4 ++-- resources/views/pages/settings/password.twig | 6 +++--- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php index 71567f95..c74f97c2 100644 --- a/includes/pages/admin_user.php +++ b/includes/pages/admin_user.php @@ -119,8 +119,8 @@ function admin_user() . '" method="post">' . "\n"; $html .= form_csrf(); $html .= '' . "\n"; - $html .= ' ' . "\n"; - $html .= ' ' . "\n"; + $html .= ' ' . "\n"; + $html .= ' ' . "\n"; $html .= '
Passwort' . '
Wiederholung' . '
Passwort' . '
Wiederholung' . '
' . "\n" . '
' . "\n"; $html .= '' . "\n"; diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index 0a5474ef..98c224cf 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -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', [ diff --git a/includes/sys_form.php b/includes/sys_form.php index 7712eaa4..d487c9d7 100644 --- a/includes/sys_form.php +++ b/includes/sys_form.php @@ -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( - '', + '', $name, config('min_password_length'), + $autocomplete, $disabled ), 'form_' . $name diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 66ca9b47..1e5b9051 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -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')) ]) ]); diff --git a/resources/views/macros/form.twig b/resources/views/macros/form.twig index f20a9cf0..351052a3 100644 --- a/resources/views/macros/form.twig +++ b/resources/views/macros/form.twig @@ -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 -%} diff --git a/resources/views/pages/login.twig b/resources/views/pages/login.twig index 0bf31660..c7ee7b90 100644 --- a/resources/views/pages/login.twig +++ b/resources/views/pages/login.twig @@ -58,8 +58,8 @@ diff --git a/resources/views/pages/settings/password.twig b/resources/views/pages/settings/password.twig index 4d6e5b82..5e4a70f0 100644 --- a/resources/views/pages/settings/password.twig +++ b/resources/views/pages/settings/password.twig @@ -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')) }}