Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from web.models import User
- class EmailBackend:
- """
- Authenticate with e-mail.
- """
- supports_object_permissions = False
- supports_anonymous_user = False
- supports_inactive_user = False
- def authenticate(self, username=None, password=None):
- try: user = User.objects.get(email=username)
- except User.DoesNotExist: return None
- if user.check_password(password): return user
- return None
- def get_user(self, user_id):
- try: return User.objects.get(pk=user_id)
- except User.DoesNotExist: return None
Add Comment
Please, Sign In to add comment