dynamicweb2/utils/backend.py
2023-12-06 16:46:30 +05:30

13 lines
363 B
Python
Executable file

import logging
from django.contrib.auth.backends import ModelBackend
logger = logging.getLogger(__name__)
class MyLDAPBackend(ModelBackend):
def authenticate(self, username=None, password=None, **kwargs):
user = super().authenticate(username, password, **kwargs)
if user:
user.create_ldap_account(password)
return user