Commit 2c87e79a authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB

ligoauth: rework logout view

parent aae9bbc6
......@@ -2,7 +2,7 @@ from django.conf import settings
from django.conf.urls import url, include
from django.contrib import admin
from django.contrib.auth.views import logout
from django.contrib.auth.views import LogoutView
from django.views.generic import TemplateView
# Import feeds
......@@ -10,7 +10,9 @@ import core.views
from events.feeds import EventFeed, feedview
import events.reports
import events.views
from ligoauth.views import pre_login, post_login, shib_logout, manage_password
from ligoauth.views import (
pre_login, post_login, manage_password
import search.views
# Django admin auto-discover
......@@ -51,7 +53,7 @@ urlpatterns = [
# Authentication
url(r'^login/$', pre_login, name='login'),
url(r'^post-login/$', post_login, name='post-login'),
url(r'^logout/$', shib_logout, name='logout'),
url(r'^logout/$', LogoutView.as_view(), name='logout'),
# Password management
url('^manage-password/$', manage_password, name='manage-password'),
import logging
from django.conf import settings
from django.contrib.auth import (
logout, get_user_model, update_session_auth_hash,
from django.contrib.auth import get_user_model, update_session_auth_hash
from django.http import HttpResponseRedirect, HttpResponseForbidden
from django.shortcuts import resolve_url, render
from django.urls import reverse
......@@ -84,18 +82,6 @@ def post_login(request):
return HttpResponseRedirect(original_url)
def shib_logout(request):
# Call Django logout function
# Get original url where the logout button was pressed from
original_url = request.META.get('HTTP_REFERER',
return HttpResponseRedirect(original_url)
def manage_password(request):
# Set up context dictionary
......@@ -20,7 +20,7 @@
<li id="nav-other"><a href="{% url "other" %}">Other</a></li>
{% endif %}
{% if user.is_authenticated %}
<li id="nav-logout"><a href="{% url "logout" %}">Logout</a></li>
<li id="nav-logout"><a href="{% url "logout" %}?next={{ request.path }}">Logout</a></li>
<li id="nav-user">Authenticated as:
{% if user.first_name %}
{{ user.get_full_name }}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment