Commit 5cb37e85 by Ricardo Kirkner

support custom user model instead of hardcoded contrib User model

this requires to depend on django >= 1.5
parents d091f448 5b0d782e
......@@ -97,8 +97,8 @@ def _openid_login(instance, request, error_message='', extra_context=None):
if not request.user.is_staff:
return views.default_render_failure(
request, "User %s does not have admin/staff access."
% request.user.username)
request, "%s %s does not have admin/staff access."
% (settings.AUTH_USER_MODEL, request.user.username))
# No error message was supplied
assert error_message, "Unknown Error: %s" % error_message
......
......@@ -35,7 +35,8 @@ __metaclass__ = type
import re
from django.conf import settings
from django.contrib.auth.models import User, Group, Permission
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group, Permission
from openid.consumer.consumer import SUCCESS
from openid.extensions import ax, sreg, pape
......@@ -50,6 +51,9 @@ from django_openid_auth.exceptions import (
)
User = get_user_model()
class OpenIDBackend:
"""A django.contrib.auth backend that authenticates the user based on
an OpenID response."""
......
......@@ -29,8 +29,9 @@
from __future__ import unicode_literals
from django.conf import settings
from django.db import models
from django.contrib.auth.models import Permission, User
from django.contrib.auth.models import Permission
class Nonce(models.Model):
......@@ -55,7 +56,7 @@ class Association(models.Model):
class UserOpenID(models.Model):
user = models.ForeignKey(User)
user = models.ForeignKey(settings.AUTH_USER_MODEL)
claimed_id = models.TextField(max_length=2047, unique=True)
display_id = models.TextField(max_length=2047)
......
......@@ -43,7 +43,7 @@ from setuptools import find_packages, setup
description, long_description = __doc__.split('\n\n', 1)
VERSION = '0.6'
VERSION = '0.7'
setup(
name='django-openid-auth',
......@@ -51,7 +51,7 @@ setup(
packages=find_packages(),
install_requires=[
'django>=1.4',
'django>=1.5',
'python-openid>=2.2.0',
'south',
],
......
[tox]
envlist =
py2.7-django1.4, py2.7-django1.5, py2.7-django1.6, py2.7-django1.7, py2.7-django1.8
py2.7-django1.5, py2.7-django1.6, py2.7-django1.7, py2.7-django1.8
[testenv]
commands = python manage.py test django_openid_auth
......@@ -8,13 +8,6 @@ deps=
mock
python-openid
[testenv:py2.7-django1.4]
basepython = python2.7
deps =
django >= 1.4, < 1.5
{[testenv]deps}
south==1.0
[testenv:py2.7-django1.5]
basepython = python2.7
deps =
......
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