diff --git a/lemonauth/__init__.py b/lemonauth/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/lemonauth/static/lemonauth/css/login.styl b/lemonauth/static/lemonauth/css/login.styl
new file mode 100644
index 0000000..9b9e7a5
--- /dev/null
+++ b/lemonauth/static/lemonauth/css/login.styl
@@ -0,0 +1,4 @@
+.container
+ display flex
+ flex-direction column
+ justify-content center
diff --git a/lemonauth/templates/lemonauth/login.html b/lemonauth/templates/lemonauth/login.html
new file mode 100644
index 0000000..4f762a1
--- /dev/null
+++ b/lemonauth/templates/lemonauth/login.html
@@ -0,0 +1,46 @@
+{% extends 'lemoncurry/layout.html' %}
+{% load lemonauth_tags static %}
+{% block title %}log in ~ {{ block.super }}{% endblock %}
+
+{% block styles %}
+
+{% endblock %}
+
+{% block main %}
+
+ {% if form.errors %}
+
+ Uh oh! Your username and password didn't match. Please try again.
+
+ {% endif %}
+
+ {% if next %}
+ {% if user.is_authenticated %}
+
+ Hang on! Your account doesn't have access to this page. To proceed, please log in to an account that does have access.
+
+ {% else %}
+
+ Oops! Please log in to see this page.
+
+ {% endif %}
+ {% endif %}
+
+
+
+{% endblock %}
diff --git a/lemonauth/templates/lemonauth/tags/form_field.html b/lemonauth/templates/lemonauth/tags/form_field.html
new file mode 100644
index 0000000..80e319c
--- /dev/null
+++ b/lemonauth/templates/lemonauth/tags/form_field.html
@@ -0,0 +1,6 @@
+
diff --git a/lemonauth/templatetags/__init__.py b/lemonauth/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/lemonauth/templatetags/lemonauth_tags.py b/lemonauth/templatetags/lemonauth_tags.py
new file mode 100644
index 0000000..65a196d
--- /dev/null
+++ b/lemonauth/templatetags/lemonauth_tags.py
@@ -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}
diff --git a/lemonauth/urls.py b/lemonauth/urls.py
new file mode 100644
index 0000000..a52aa57
--- /dev/null
+++ b/lemonauth/urls.py
@@ -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'),
+]
diff --git a/lemonauth/views.py b/lemonauth/views.py
new file mode 100644
index 0000000..d2cd871
--- /dev/null
+++ b/lemonauth/views.py
@@ -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()
diff --git a/lemoncurry/settings/base.py b/lemoncurry/settings/base.py
index ed15b6d..1ec21b4 100644
--- a/lemoncurry/settings/base.py
+++ b/lemoncurry/settings/base.py
@@ -70,6 +70,7 @@ INSTALLED_APPS = [
'lemoncurry',
'home',
+ 'lemonauth',
'users',
'wellknowns',
]
@@ -147,6 +148,10 @@ AUTH_PASSWORD_VALIDATORS = [
},
]
+LOGIN_URL = 'lemonauth:login'
+LOGIN_REDIRECT_URL = 'home:index'
+LOGOUT_REDIRECT_URL = LOGIN_REDIRECT_URL
+
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
diff --git a/lemoncurry/templates/lemoncurry/layout.html b/lemoncurry/templates/lemoncurry/layout.html
index 3dfd4af..cb7ba3d 100644
--- a/lemoncurry/templates/lemoncurry/layout.html
+++ b/lemoncurry/templates/lemoncurry/layout.html
@@ -1,7 +1,7 @@
{% load compress favtags lemoncurry_tags meta static %}
- {% site_name %}
+ {% block title %}{% site_name %}{% endblock %}
{% include 'meta/meta.html' %}
@@ -11,6 +11,7 @@
integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous" />
{% compress css %}
+ {% block styles %}{% endblock %}
{% endcompress %}
diff --git a/lemoncurry/templatetags/lemoncurry_tags.py b/lemoncurry/templatetags/lemoncurry_tags.py
index e463570..1d8b9d2 100644
--- a/lemoncurry/templatetags/lemoncurry_tags.py
+++ b/lemoncurry/templatetags/lemoncurry_tags.py
@@ -43,10 +43,10 @@ def nav_right(request):
if request.user.is_authenticated():
items = (
MenuItem(label='admin', icon='fa fa-gear', url='admin:index'),
- MenuItem(label='log out', icon='fa fa-sign-out', url='admin:logout'),
+ MenuItem(label='log out', icon='fa fa-sign-out', url='lemonauth:logout'),
)
else:
items = (
- MenuItem(label='log in', icon='fa fa-sign-in', url='admin:login'),
+ MenuItem(label='log in', icon='fa fa-sign-in', url='lemonauth:login'),
)
return {'items': items}
diff --git a/lemoncurry/urls.py b/lemoncurry/urls.py
index a9303b1..eb27069 100644
--- a/lemoncurry/urls.py
+++ b/lemoncurry/urls.py
@@ -28,6 +28,7 @@ urlpatterns = [
url('', include('home.urls')),
url('^.well-known/', include('wellknowns.urls')),
url('^admin/', admin.site.urls),
+ url('^auth/', include('lemonauth.urls')),
url(r'^sitemap\.xml$', sitemap.index, maps),
url(r'^sitemaps/(?P.+)\.xml$', sitemap.sitemap, maps,