Created
September 18, 2010 21:33
-
-
Save rainerborene/586056 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.backends import ModelBackend | |
from django.contrib.auth.models import User | |
class EmailBackend(ModelBackend): | |
def authenticate(self, **credentials): | |
if 'username' in credentials: | |
return super(EmailBackend, self).authenticate(**credentials) | |
try: | |
user = User.objects.get(email=credentials.get('email')) | |
if user.check_password(credentials.get('password')): | |
return user | |
except User.DoesNotExist: | |
return None | |
Yes, you missed the complete path of your backend. You should use the following pattern: projectname.applicationname.backends.EmailBackend
. Remember that Google is your friend ;-)
thanks dude,
Now i'm getting this(I swear I have researched this one enough on the internet before ask you ;) ):
Exception Value:
Module "goow.myAutenticate" does not define a "EmailBackend" authentication backend
Maybe you'll need:
Django Version: 1.2.5
Exception Type: ImproperlyConfigured
Exception Location: /usr/local/lib/python2.6/dist-packages/django/contrib/auth/init.py in load_backend, line 22
Python Executable: /usr/bin/python2.6
Python Version: 2.6.6
I really appreciate.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
on the settings.py , i created:
AUTHENTICATION_BACKENDS = (
'myAutenticate',
'django.contrib.auth.backends.ModelBackend',
)
then, i created an app named myAutenticate. After, i created the backends.py inside the folder myAutenticate and placed the that you suggested on this gist topic.
now, i'm getting the following error message: "Error importing authentication backend myAutenticat: "No module named myAutenticat"
do i miss something?