Commit d3fd4f75 by Dave Walker (Daviey)

Removed exception hiding of admin login overiding, to throw an error if it fails…

Removed exception hiding of admin login overiding, to throw an error if it fails rather than silently falling back to normal form.
parent 75bf5dd9
......@@ -2,7 +2,7 @@
#
# Copyright (C) 2007 Simon Willison
# Copyright (C) 2008-2009 Canonical Ltd.
# Copyright (c) 2010 Dave Walker
# Copyright (C) 2010 Dave Walker
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
......@@ -32,27 +32,21 @@
from django.conf import settings
try:
if getattr(settings, 'OPENID_USE_AS_ADMIN_LOGIN', False):
from django.http import HttpResponseRedirect
from django.contrib.admin import sites
from django_openid_auth import views
def _openid_login(self, request, error_message='', extra_context=None):
if request.user.is_authenticated():
if not request.user.is_staff:
return views.render_failure(request, "User %s does not have admin access."
% request.user.username)
return views.render_failure(request, "Unknown Error: %s" % error_message)
else:
# Redirect to openid login path,
return HttpResponseRedirect(settings.LOGIN_URL+"?next="+request.get_full_path())
# Overide the standard admin login form.
sites.AdminSite.display_login_form = _openid_login
except:
# An error occured overiding, silently fall back to upstream login form.
pass
if getattr(settings, 'OPENID_USE_AS_ADMIN_LOGIN', False):
from django.http import HttpResponseRedirect
from django.contrib.admin import sites
from django_openid_auth import views
def _openid_login(self, request, error_message='', extra_context=None):
if request.user.is_authenticated():
if not request.user.is_staff:
return views.render_failure(request, "User %s does not have admin access."
% request.user.username)
return views.render_failure(request, "Unknown Error: %s" % error_message)
else:
# Redirect to openid login path,
return HttpResponseRedirect(settings.LOGIN_URL+"?next="+request.get_full_path())
# Overide the standard admin login form.
sites.AdminSite.display_login_form = _openid_login
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment