Files
modoboa/lib/authbackends.py
T
tonio ab5b8d96c3 Authentication mechanism changed. I don't use Django's builtin
passwords encryption anymore because the default format is something
like : <algo>$<salt>$<password>
I really think this format is not compatible with external softwares
so I use simple hashes.
2009-03-27 09:25:09 +01:00

24 lines
678 B
Python

from django.contrib.auth.models import User
from mailng.admin.models import Mailbox
import md5
class SimpleBackend:
def authenticate(self, username=None, password=None):
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
return None
try:
mb = Mailbox.objects.get(full_address=username)
except Exception:
return None
if mb.password != md5.new(password).hexdigest():
return None
return user
def get_user(self, user_id):
try:
return User.objects.get(pk=user_id)
except User.DoesNotExist:
return None