mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-28 11:26:26 -06:00
Clean up login template & form
This commit is contained in:
parent
06b80b060c
commit
84c6b3cfda
@ -1,53 +1,58 @@
|
||||
{% extends 'base.html' %} {% load static %} {% block layout %}
|
||||
<main class="login-container text-center">
|
||||
{% if settings.BANNER_LOGIN %}
|
||||
<div class="alert alert-secondary" role="alert">
|
||||
{{ settings.BANNER_LOGIN|safe }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="form-login">
|
||||
<form action="{% url 'login' %}" method="post">
|
||||
<div class="mb-4">
|
||||
{% include 'logo.html' with height=80 %}
|
||||
{# User login page. Extends base.html directly to override normal UI layout. #}
|
||||
{% extends 'base.html' %}
|
||||
{% load form_helpers %}
|
||||
{% load static %}
|
||||
|
||||
{% block layout %}
|
||||
<main class="login-container text-center">
|
||||
|
||||
{# Login banner #}
|
||||
{% if settings.BANNER_LOGIN %}
|
||||
<div class="alert alert-secondary" role="alert">
|
||||
{{ settings.BANNER_LOGIN|safe }}
|
||||
</div>
|
||||
{% csrf_token %} {% if 'next' in request.GET %}
|
||||
<input type="hidden" name="next" value="{{ request.GET.next }}" />
|
||||
{% endif %} {% if 'next' in request.POST %}
|
||||
<input type="hidden" name="next" value="{{ request.POST.next }}" />
|
||||
{% endif %}
|
||||
<input
|
||||
required
|
||||
type="text"
|
||||
placeholder="Username"
|
||||
name="username"
|
||||
maxlength="150"
|
||||
id="id_username"
|
||||
class="form-control"
|
||||
/>
|
||||
<input
|
||||
required
|
||||
type="password"
|
||||
placeholder="Password"
|
||||
name="password"
|
||||
id="id_password"
|
||||
class="form-control"
|
||||
/>
|
||||
<button type="submit" class="btn btn-primary btn-lg w-100 mt-4">
|
||||
Sign In
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
{% load form_helpers %} {% if form.non_field_errors %}
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<h4 class="alert-heading">Errors</h4>
|
||||
<p>
|
||||
{{ form.non_field_errors }}
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</main>
|
||||
<footer class="footer container-fluid login-footer py-3">
|
||||
<div class="row align-items-center">
|
||||
{% endif %}
|
||||
|
||||
{# Login form #}
|
||||
<div class="form-login">
|
||||
<form action="{% url 'login' %}" method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
{# Logo #}
|
||||
<div class="mb-4">
|
||||
{% include 'logo.html' with height=80 %}
|
||||
</div>
|
||||
|
||||
{# Set post-login URL #}
|
||||
{% if 'next' in request.GET %}
|
||||
<input type="hidden" name="next" value="{{ request.GET.next }}" />
|
||||
{% endif %} {% if 'next' in request.POST %}
|
||||
<input type="hidden" name="next" value="{{ request.POST.next }}" />
|
||||
{% endif %}
|
||||
|
||||
{{ form.username }}
|
||||
{{ form.password }}
|
||||
|
||||
<button type="submit" class="btn btn-primary btn-lg w-100 mt-4">
|
||||
Sign In
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{# Login form errors #}
|
||||
{% if form.non_field_errors %}
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<h4 class="alert-heading">Errors</h4>
|
||||
<p>
|
||||
{{ form.non_field_errors }}
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</main>
|
||||
|
||||
{# Page footer #}
|
||||
<footer class="footer container-fluid login-footer py-3">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-2 col-md-1 mb-0">
|
||||
<button type="button" class="btn btn-sm color-mode-toggle" title="Toggle Color Mode">
|
||||
<i class="color-mode-icon mdi mdi-lightbulb"></i>
|
||||
@ -59,6 +64,7 @@
|
||||
{{ settings.HOSTNAME }} (v{{ settings.VERSION }})
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
{% endblock %}
|
||||
|
@ -6,12 +6,7 @@ from .models import Token
|
||||
|
||||
|
||||
class LoginForm(BootstrapMixin, AuthenticationForm):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.fields['username'].widget.attrs['placeholder'] = ''
|
||||
self.fields['password'].widget.attrs['placeholder'] = ''
|
||||
pass
|
||||
|
||||
|
||||
class PasswordChangeForm(BootstrapMixin, DjangoPasswordChangeForm):
|
||||
|
Loading…
Reference in New Issue
Block a user