Authentication - Add logout view and set login url in settings

This commit is contained in:
Evert Prants 2017-11-14 15:32:26 +02:00
parent 9f725b4c46
commit 0bded3afc7
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
3 changed files with 7 additions and 0 deletions

View File

@ -72,6 +72,7 @@ MIDDLEWARE = [
]
ROOT_URLCONF = 'EpisodesCommunity.urls'
LOGIN_URL = '/login'
TEMPLATES = [
{

View File

@ -3,6 +3,7 @@ from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^logout/$', views.LogoutView),
url(r'^login/redirect$', views.LoginRedirect.as_view()),
url(r'^login$', views.Login.as_view()),
url(r'^$', views.LandingPage.as_view()),

View File

@ -6,6 +6,7 @@ from django.conf import settings
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from django.db.models import Max
from django.contrib.auth.views import logout
import requests
import hashlib
import json
@ -50,6 +51,10 @@ class Login(View):
response['Location'] = url
return response
def LogoutView(request):
logout(request)
return HttpResponseRedirect('/')
def generateState(request):
request.session.save()