consistent block structure for login form overrides

- `{name}_input` for overriding full input
- `{name}_input_attrs` for overriding input element attributes (not including id).
  Use `super()` to extend.
- For all `name` in username, password, otp
This commit is contained in:
Min RK
2025-02-19 13:07:45 +01:00
parent 0521270862
commit 681a7ae840

View File

@@ -35,9 +35,10 @@
{% if login_error %}<p class="login_error">{{ login_error }}</p>{% endif %} {% if login_error %}<p class="login_error">{{ login_error }}</p>{% endif %}
<input type="hidden" name="_xsrf" value="{{ xsrf }}" /> <input type="hidden" name="_xsrf" value="{{ xsrf }}" />
{# Allow full override of the "label" and "input" elements of the username and password fields. #} {# Allow full override of the "label" and "input" elements of the username and password fields. #}
{% block username_password_input_override %} {% block username_input %}
<label for="username_input">Username:</label> <label for="username_input">Username:</label>
<input id="username_input" <input id="username_input"
{% block username_input_attrs %}
type="text" type="text"
autocapitalize="off" autocapitalize="off"
autocorrect="off" autocorrect="off"
@@ -46,25 +47,28 @@
name="username" name="username"
val="{{ username }}" val="{{ username }}"
autofocus="autofocus" autofocus="autofocus"
{# allow adding extra HTML Input Attributes (pattern, placeholder, title, minlenght, maxlenght, ...) #} {% endblock username_input_attrs %} />
{% block username_input_attribs %}{% endblock username_input_attribs %} {% endblock username_input %}
/> {% block password_input %}
<label for='password_input'>Password:</label> <label for='password_input'>Password:</label>
<input type="password" <input id="password_input"
{% block password_input_attrs %}
type="password"
class="form-control" class="form-control"
autocomplete="current-password" autocomplete="current-password"
name="password" name="password"
id="password_input" {% endblock password_input_attrs %} />
{# allow adding extra HTML Input Attributes (pattern, placeholder, title, minlenght, maxlenght, ...) #} {% endblock password_input %}
{% block password_input_attribs %}{% endblock password_input_attribs %}
/>
{% endblock username_password_input_override %}
{% if authenticator.request_otp %} {% if authenticator.request_otp %}
<label for='otp_input'>{{ authenticator.otp_prompt }}</label> {% block otp_input %}
<input class="form-control" <label for="otp_input">{{ authenticator.otp_prompt }}</label>
<input id="otp_input"
{% block otp_input_attrs %}
class="form-control"
autocomplete="one-time-password" autocomplete="one-time-password"
name="otp" name="otp"
id="otp_input" /> {% endblock otp_input_attrs %} />
{% endblock otp_input %}
{% endif %} {% endif %}
<div class="feedback-container"> <div class="feedback-container">
<input id="login_submit" <input id="login_submit"