Commit f1b86c84 by Mike Heald

Fixes to make backend compliant with django-1.3, changed admin monkeypatch to…

Fixes to make backend compliant with django-1.3, changed admin monkeypatch to work with django-1.3 admin and OPENID_USE_AS_ADMIN_LOGIN
parent 5858c943
...@@ -76,7 +76,7 @@ if getattr(settings, 'OPENID_USE_AS_ADMIN_LOGIN', False): ...@@ -76,7 +76,7 @@ if getattr(settings, 'OPENID_USE_AS_ADMIN_LOGIN', False):
def _openid_login(self, request, error_message='', extra_context=None): def _openid_login(self, request, error_message='', extra_context=None):
if request.user.is_authenticated(): if request.user.is_authenticated():
if not request.user.is_staff: if not request.user.is_staff:
return views.render_failure( return views.default_render_failure(
request, "User %s does not have admin access." request, "User %s does not have admin access."
% request.user.username) % request.user.username)
return views.render_failure( return views.render_failure(
...@@ -87,4 +87,4 @@ if getattr(settings, 'OPENID_USE_AS_ADMIN_LOGIN', False): ...@@ -87,4 +87,4 @@ if getattr(settings, 'OPENID_USE_AS_ADMIN_LOGIN', False):
settings.LOGIN_URL + "?next=" + request.get_full_path()) settings.LOGIN_URL + "?next=" + request.get_full_path())
# Overide the standard admin login form. # Overide the standard admin login form.
admin.sites.AdminSite.display_login_form = _openid_login admin.sites.AdminSite.login = _openid_login
...@@ -49,6 +49,9 @@ class OpenIDBackend: ...@@ -49,6 +49,9 @@ class OpenIDBackend:
"""A django.contrib.auth backend that authenticates the user based on """A django.contrib.auth backend that authenticates the user based on
an OpenID response.""" an OpenID response."""
supports_object_permissions = False
supports_anonymous_user = True
def get_user(self, user_id): def get_user(self, user_id):
try: try:
return User.objects.get(pk=user_id) return User.objects.get(pk=user_id)
...@@ -198,10 +201,8 @@ class OpenIDBackend: ...@@ -198,10 +201,8 @@ class OpenIDBackend:
"already in use for a different account." % nickname) "already in use for a different account." % nickname)
# Pick a username for the user based on their nickname, # Pick a username for the user based on their nickname,
# checking for conflicts. Start with number of existing users who's # checking for conflicts.
# username starts with this nickname to avoid having to iterate over i = 1
# all of the existing ones.
i = User.objects.filter(username__startswith=nickname).count() + 1
while True: while True:
username = nickname username = nickname
if i > 1: if i > 1:
......
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