Skip to content

Commit

Permalink
Merge branch 'master' into wakawaka_integration
Browse files Browse the repository at this point in the history
  • Loading branch information
brosner committed Jul 21, 2010
2 parents 3d0f6e9 + 8787f8f commit 80ff614
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 81 deletions.
25 changes: 16 additions & 9 deletions pinax/apps/account/auth_backends.py
@@ -1,17 +1,24 @@
from django.conf import settings

from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.models import User



class EmailModelBackend(ModelBackend):
"""
A backend that provides authentication through e-mail instead of username.
"""
class AuthenticationBackend(ModelBackend):

def authenticate(self, email=None, password=None):
def authenticate(self, **credentials):
lookup_params = {}
if settings.ACCOUNT_EMAIL_AUTHENTICATION:
lookup_params["email"] = credentials["email"]
else:
lookup_params["username"] = credentials["username"]
try:
user = User.objects.get(email=email)
if user.check_password(password):
return user
user = User.objects.get(**lookup_params)
except User.DoesNotExist:
return None
else:
if user.check_password(credentials["password"]):
return user


EmailModelBackend = AuthenticationBackend
11 changes: 3 additions & 8 deletions pinax/projects/account_project/settings.py
Expand Up @@ -168,14 +168,9 @@
ACCOUNT_EMAIL_AUTHENTICATION = False
ACCOUNT_UNIQUE_EMAIL = EMAIL_CONFIRMATION_UNIQUE_EMAIL = False

if ACCOUNT_EMAIL_AUTHENTICATION:
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.EmailModelBackend",
]
else:
AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
]
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.AuthenticationBackend",
]

LOGIN_URL = "/account/login/" # @@@ any way this can be a url name?
LOGIN_REDIRECT_URLNAME = "what_next"
Expand Down
11 changes: 3 additions & 8 deletions pinax/projects/basic_project/settings.py
Expand Up @@ -185,14 +185,9 @@
ACCOUNT_EMAIL_AUTHENTICATION = False
ACCOUNT_UNIQUE_EMAIL = EMAIL_CONFIRMATION_UNIQUE_EMAIL = False

if ACCOUNT_EMAIL_AUTHENTICATION:
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.EmailModelBackend",
]
else:
AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
]
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.AuthenticationBackend",
]

LOGIN_URL = "/account/login/" # @@@ any way this can be a url name?
LOGIN_REDIRECT_URLNAME = "what_next"
Expand Down
11 changes: 3 additions & 8 deletions pinax/projects/cms_company_project/settings.py
Expand Up @@ -198,14 +198,9 @@
ACCOUNT_EMAIL_AUTHENTICATION = False
ACCOUNT_UNIQUE_EMAIL = EMAIL_CONFIRMATION_UNIQUE_EMAIL = False

if ACCOUNT_EMAIL_AUTHENTICATION:
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.EmailModelBackend",
]
else:
AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
]
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.AuthenticationBackend",
]

EMAIL_CONFIRMATION_DAYS = 2
EMAIL_DEBUG = DEBUG
Expand Down
11 changes: 3 additions & 8 deletions pinax/projects/cms_holidayhouse_project/settings.py
Expand Up @@ -198,14 +198,9 @@
ACCOUNT_EMAIL_AUTHENTICATION = False
ACCOUNT_UNIQUE_EMAIL = EMAIL_CONFIRMATION_UNIQUE_EMAIL = False

if ACCOUNT_EMAIL_AUTHENTICATION:
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.EmailModelBackend",
]
else:
AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
]
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.AuthenticationBackend",
]

EMAIL_CONFIRMATION_DAYS = 2
EMAIL_DEBUG = DEBUG
Expand Down
11 changes: 3 additions & 8 deletions pinax/projects/code_project/settings.py
Expand Up @@ -214,14 +214,9 @@
ACCOUNT_EMAIL_AUTHENTICATION = False
ACCOUNT_UNIQUE_EMAIL = EMAIL_CONFIRMATION_UNIQUE_EMAIL = False

if ACCOUNT_EMAIL_AUTHENTICATION:
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.EmailModelBackend",
]
else:
AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
]
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.AuthenticationBackend",
]

LOGIN_URL = "/account/login/" # @@@ any way this can be a url name?
LOGIN_REDIRECT_URLNAME = "what_next"
Expand Down
11 changes: 3 additions & 8 deletions pinax/projects/intranet_project/settings.py
Expand Up @@ -209,14 +209,9 @@
ACCOUNT_EMAIL_AUTHENTICATION = False
ACCOUNT_UNIQUE_EMAIL = EMAIL_CONFIRMATION_UNIQUE_EMAIL = False

if ACCOUNT_EMAIL_AUTHENTICATION:
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.EmailModelBackend",
]
else:
AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
]
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.AuthenticationBackend",
]

LOGIN_URL = "/account/login/" # @@@ any way this can be a url name?
LOGIN_REDIRECT_URLNAME = "home"
Expand Down
11 changes: 3 additions & 8 deletions pinax/projects/private_beta_project/settings.py
Expand Up @@ -170,14 +170,9 @@
ACCOUNT_EMAIL_AUTHENTICATION = False
ACCOUNT_UNIQUE_EMAIL = EMAIL_CONFIRMATION_UNIQUE_EMAIL = False

if ACCOUNT_EMAIL_AUTHENTICATION:
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.EmailModelBackend",
]
else:
AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
]
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.AuthenticationBackend",
]

LOGIN_URL = "/account/login/"
LOGIN_REDIRECT_URLNAME = "what_next"
Expand Down
11 changes: 3 additions & 8 deletions pinax/projects/sample_group_project/settings.py
Expand Up @@ -216,14 +216,9 @@
ACCOUNT_EMAIL_AUTHENTICATION = False
ACCOUNT_UNIQUE_EMAIL = EMAIL_CONFIRMATION_UNIQUE_EMAIL = False

if ACCOUNT_EMAIL_AUTHENTICATION:
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.EmailModelBackend",
]
else:
AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
]
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.AuthenticationBackend",
]

LOGIN_URL = "/account/login/" # @@@ any way this can be a url name?
LOGIN_REDIRECT_URLNAME = "what_next"
Expand Down
11 changes: 3 additions & 8 deletions pinax/projects/social_project/settings.py
Expand Up @@ -230,14 +230,9 @@
ACCOUNT_EMAIL_AUTHENTICATION = False
ACCOUNT_UNIQUE_EMAIL = EMAIL_CONFIRMATION_UNIQUE_EMAIL = False

if ACCOUNT_EMAIL_AUTHENTICATION:
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.EmailModelBackend",
]
else:
AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
]
AUTHENTICATION_BACKENDS = [
"pinax.apps.account.auth_backends.AuthenticationBackend",
]

LOGIN_URL = "/account/login/" # @@@ any way this can be a url name?
LOGIN_REDIRECT_URLNAME = "what_next"
Expand Down

0 comments on commit 80ff614

Please sign in to comment.