add authentication views
authorFrédéric Péters <fpeters@0d.be>
Sun, 29 Dec 2019 14:09:34 +0000 (15:09 +0100)
committerFrédéric Péters <fpeters@0d.be>
Mon, 30 Dec 2019 08:35:50 +0000 (09:35 +0100)
chloro/phyll/templates/registration/login.html [new file with mode: 0644]
chloro/settings.py
chloro/urls.py

diff --git a/chloro/phyll/templates/registration/login.html b/chloro/phyll/templates/registration/login.html
new file mode 100644 (file)
index 0000000..2e89da4
--- /dev/null
@@ -0,0 +1,11 @@
+{% extends "phyll/base.html" %}
+{% load i18n %}
+
+{% block body %}
+<form method="post" action="{% url 'login' %}">
+{% csrf_token %}
+{{ form.as_p }}
+<button name="login">{% trans "Login" %}</button>
+<input type="hidden" name="next" value="{{ next }}" />
+</form>
+{% endblock %}
index 4ee2cfe..f3d06cd 100644 (file)
@@ -89,6 +89,8 @@ AUTH_PASSWORD_VALIDATORS = [
     {'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',},
 ]
 
+LOGIN_REDIRECT_URL = '/'
+LOGIN_URL = 'login'
 
 # Internationalization
 # https://docs.djangoproject.com/en/1.11/topics/i18n/
index 032add7..d84a5e5 100644 (file)
 from django.conf import settings
 from django.conf.urls import include, url
 from django.conf.urls.static import static
+from django.contrib.auth import views as auth_views
 from django.contrib.staticfiles.urls import staticfiles_urlpatterns
 
-urlpatterns = []
+urlpatterns = [
+    url(r'^accounts/login/$', auth_views.LoginView.as_view(), name='login'),
+    url(r'^accounts/logout/$', auth_views.LogoutView.as_view(), name='logout'),
+]
 
 # static and media files
 urlpatterns += staticfiles_urlpatterns()