Skip to content

Commit

Permalink
Made various login redirects more intuative
Browse files Browse the repository at this point in the history
  • Loading branch information
dlareau committed Mar 22, 2020
1 parent 4bb9e98 commit 4785d04
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion huntserver/auth_views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.conf import settings
from django.contrib import messages
from django.contrib.auth import logout, login, views
from django.contrib.auth.models import User
from django.shortcuts import render, redirect
Expand Down Expand Up @@ -61,13 +62,14 @@ def account_logout(request):
""" A view to logout the user and *hopefully* also logout out the shibboleth system. """

logout(request)
messages.success(request, "Logout successful")
if 'next' in request.GET:
additional_url = request.GET['next']
else:
additional_url = ""
if(settings.USE_SHIBBOLETH):
next_url = "https://" + request.get_host() + additional_url
return redirect("/Shibboleth.sso/Logout?next=" + next_url)
return redirect("/Shibboleth.sso/Logout?return=" + next_url)
else:
return index(request)

Expand Down
2 changes: 1 addition & 1 deletion puzzlehunt_server/settings/base_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
# URL settings
LOGIN_REDIRECT_URL = '/'
PROTECTED_URL = '/protected/'
LOGIN_URL = 'login_selection'
LOGIN_URL = 'huntserver:login_selection'

# Random settings
SILENCED_SYSTEM_CHECKS = ["urls.W005"] # silences admin url override warning
Expand Down
4 changes: 4 additions & 0 deletions puzzlehunt_server/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

urlpatterns = [
# Admin redirections/views
url(r'^admin/login/$', RedirectView.as_view(url=reverse_lazy(settings.LOGIN_URL),
query_string=True)),
url(r'^staff/login/$', RedirectView.as_view(url=reverse_lazy(settings.LOGIN_URL),
query_string=True)),
url(r'^admin/$', RedirectView.as_view(url=reverse_lazy('admin:app_list',
args=('huntserver',)))),
url(r'^staff/$', RedirectView.as_view(url=reverse_lazy('admin:app_list',
Expand Down

0 comments on commit 4785d04

Please sign in to comment.