Switch from using the admin login/logout pages to custom 'lemonauth' pages
parent
1670b6d427
commit
c210650ca7
@ -0,0 +1,4 @@
|
||||
.container
|
||||
display flex
|
||||
flex-direction column
|
||||
justify-content center
|
@ -0,0 +1,46 @@
|
||||
{% extends 'lemoncurry/layout.html' %}
|
||||
{% load lemonauth_tags static %}
|
||||
{% block title %}log in ~ {{ block.super }}{% endblock %}
|
||||
|
||||
{% block styles %}
|
||||
<link rel="stylesheet" type="text/stylus" href="{% static 'lemonauth/css/login.styl' %}" />
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<div class="container">
|
||||
{% if form.errors %}
|
||||
<p class="alert alert-danger">
|
||||
<strong>Uh oh!</strong> Your username and password didn't match. Please try again.
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if next %}
|
||||
{% if user.is_authenticated %}
|
||||
<p class="alert alert-warning">
|
||||
<strong>Hang on!</strong> Your account doesn't have access to this page. To proceed, please log in to an account that does have access.
|
||||
</p>
|
||||
{% else %}
|
||||
<p class="alert alert-warning">
|
||||
<strong>Oops!</strong> Please log in to see this page.
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<form class="card" method="post" action="{% url 'lemonauth:login' %}">
|
||||
<div class="card-body">
|
||||
{% form_field form.username %}
|
||||
{% form_field form.password %}
|
||||
</div>
|
||||
|
||||
<div class="card-footer">
|
||||
<button class="btn btn-primary" type="submit">
|
||||
<i class="fa fa-sign-in"></i>
|
||||
log in
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="next" value="{{ next }}" />
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
@ -0,0 +1,6 @@
|
||||
<div class="form-group{% if field.errors %} has-error{% endif %}">
|
||||
<label for="{{ field.id_for_label }}">{{ field.label | lower }}</label>
|
||||
<input id="{{ field.id_for_label }}" class="form-control" type="{{ field.field.widget.input_type }}"
|
||||
name="{{ field.html_name }}"{% if field.value %} value="{{ field.value }}"{% endif %}{% if field.help_text %} aria-describedby="{{ field.id_for_label }}-help"{% endif %} />
|
||||
{% if field.help_text %}<p id="{{ field.id_for_label }}-help" class="form-text">{{ field.help_text }}</p>{% endif %}
|
||||
</div>
|
@ -0,0 +1,8 @@
|
||||
from django import template
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.inclusion_tag('lemonauth/tags/form_field.html')
|
||||
def form_field(field):
|
||||
return {'field': field}
|
@ -0,0 +1,8 @@
|
||||
from django.conf.urls import url
|
||||
from . import views
|
||||
|
||||
app_name = 'lemonauth'
|
||||
urlpatterns = [
|
||||
url('^login$', views.login, name='login'),
|
||||
url('^logout$', views.logout, name='logout'),
|
||||
]
|
@ -0,0 +1,7 @@
|
||||
from django.contrib.auth import views as auth_views
|
||||
|
||||
login = auth_views.LoginView.as_view(
|
||||
template_name='lemonauth/login.html',
|
||||
redirect_authenticated_user=True,
|
||||
)
|
||||
logout = auth_views.LogoutView.as_view()
|
Loading…
Reference in New Issue