from django.contrib.auth.models import User
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth import login as django_login
+from django.contrib.auth import logout as django_logout
from django.conf import settings
import base64
else:
return HttpResponseRedirect(settings.PGAUTH_REDIRECT)
+# Handle logout requests by logging out of this site and then
+# redirecting to log out from the main site as well.
+def logout(request):
+ if request.user.is_authenticated():
+ django_logout(request)
+ return HttpResponseRedirect("%slogout/" % settings.PGAUTH_REDIRECT)
+
# Receive an authentication response from the main website and try
# to log the user in.
def auth_receive(request):
+ if request.GET.has_key('s') and request.GET['s'] == "logout":
+ # This was a logout request
+ return HttpResponseRedirect('/')
+
if not request.GET.has_key('i'):
raise Exception("Missing IV")
if not request.GET.has_key('d'):
from django.conf.urls.defaults import *
-from django.contrib.auth.views import logout, logout_then_login
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
(r'^login/$', 'hamnadmin.auth.login'),
(r'^auth_receive/$', 'hamnadmin.auth.auth_receive'),
- (r'^logout/$', logout_then_login, {'login_url':'/'}),
+ (r'^logout/$', 'hamnadmin.auth.logout'),
(r'^admin/', include(admin.site.urls)),
)