mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
Removed useless fields (full_address) and added associated migrations. SQL queries used by postfix or dovecot will need to be updated. (as the documentation) see #103 Big refactoring of objects creation and edition. (javascript cleanup, forms factoring, etc.)
25 lines
690 B
Python
25 lines
690 B
Python
from django.contrib.auth.models import User
|
|
from modoboa.admin.models import Mailbox
|
|
from modoboa.lib import _check_password
|
|
|
|
class SimpleBackend:
|
|
def authenticate(self, username=None, password=None):
|
|
try:
|
|
user = User.objects.get(username=username)
|
|
except User.DoesNotExist:
|
|
return None
|
|
try:
|
|
mb = user.mailbox_set.all()[0]
|
|
except Exception:
|
|
return None
|
|
if not _check_password(password, mb.password):
|
|
return None
|
|
return user
|
|
|
|
def get_user(self, user_id):
|
|
try:
|
|
return User.objects.get(pk=user_id)
|
|
except User.DoesNotExist:
|
|
return None
|
|
|