Refactor LDAP support and add LDAP caching
This commit is contained in:
@@ -2,7 +2,6 @@ from django.contrib.auth import get_user_model
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
||||
from . import app_settings
|
||||
from .ldap import LDAPConnection
|
||||
|
||||
|
||||
User = get_user_model()
|
||||
@@ -16,11 +15,6 @@ def get_user_queryset(queryset, view):
|
||||
|
||||
|
||||
def create_user(*args, **kwargs):
|
||||
# Check if the LDAP query returns exactly one user
|
||||
if app_settings.USE_LDAP:
|
||||
if not LDAPConnection.get_instance().has_user(kwargs['username']):
|
||||
raise PermissionDenied('User is not listed in the LDAP registry.')
|
||||
|
||||
custom_func = app_settings.CREATE_USER_FUNC
|
||||
if custom_func is not None:
|
||||
return custom_func(*args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user