diff --git a/myauth/ldap.py b/myauth/ldap.py index a96860d..96bc404 100644 --- a/myauth/ldap.py +++ b/myauth/ldap.py @@ -13,6 +13,7 @@ import ldap User = get_typed_user_model() + def ldap_setting(name, default): """Wrapper around django.conf.settings""" return getattr(settings, f"LDAP_{name}", default) @@ -78,10 +79,12 @@ class LDAPConnection: return True return False + def is_user_in_ldap(user: UserType = Depends(get_authenticated_user)): if not LDAPConnection.get_instance().has_user(user.username): raise PermissionDenied(detail="User not in LDAP directory.") + def create_user(context: CallbackContext, *args, **kwargs): """ A create_user function which first checks if the user already exists in the