Authentication - Add logout view and set login url in settings
This commit is contained in:
parent
9f725b4c46
commit
0bded3afc7
@ -72,6 +72,7 @@ MIDDLEWARE = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = 'EpisodesCommunity.urls'
|
ROOT_URLCONF = 'EpisodesCommunity.urls'
|
||||||
|
LOGIN_URL = '/login'
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@ from django.conf.urls import url
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
url(r'^logout/$', views.LogoutView),
|
||||||
url(r'^login/redirect$', views.LoginRedirect.as_view()),
|
url(r'^login/redirect$', views.LoginRedirect.as_view()),
|
||||||
url(r'^login$', views.Login.as_view()),
|
url(r'^login$', views.Login.as_view()),
|
||||||
url(r'^$', views.LandingPage.as_view()),
|
url(r'^$', views.LandingPage.as_view()),
|
||||||
|
@ -6,6 +6,7 @@ from django.conf import settings
|
|||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.db.models import Max
|
from django.db.models import Max
|
||||||
|
from django.contrib.auth.views import logout
|
||||||
import requests
|
import requests
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
@ -50,6 +51,10 @@ class Login(View):
|
|||||||
response['Location'] = url
|
response['Location'] = url
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
def LogoutView(request):
|
||||||
|
logout(request)
|
||||||
|
return HttpResponseRedirect('/')
|
||||||
|
|
||||||
def generateState(request):
|
def generateState(request):
|
||||||
request.session.save()
|
request.session.save()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user