Format using Black
This commit is contained in:
parent
b95662df1e
commit
2b68b55c52
@ -13,6 +13,7 @@ import ldap
|
|||||||
|
|
||||||
User = get_typed_user_model()
|
User = get_typed_user_model()
|
||||||
|
|
||||||
|
|
||||||
def ldap_setting(name, default):
|
def ldap_setting(name, default):
|
||||||
"""Wrapper around django.conf.settings"""
|
"""Wrapper around django.conf.settings"""
|
||||||
return getattr(settings, f"LDAP_{name}", default)
|
return getattr(settings, f"LDAP_{name}", default)
|
||||||
@ -78,10 +79,12 @@ class LDAPConnection:
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def is_user_in_ldap(user: UserType = Depends(get_authenticated_user)):
|
def is_user_in_ldap(user: UserType = Depends(get_authenticated_user)):
|
||||||
if not LDAPConnection.get_instance().has_user(user.username):
|
if not LDAPConnection.get_instance().has_user(user.username):
|
||||||
raise PermissionDenied(detail="User not in LDAP directory.")
|
raise PermissionDenied(detail="User not in LDAP directory.")
|
||||||
|
|
||||||
|
|
||||||
def create_user(context: CallbackContext, *args, **kwargs):
|
def create_user(context: CallbackContext, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
A create_user function which first checks if the user already exists in the
|
A create_user function which first checks if the user already exists in the
|
||||||
|
Loading…
Reference in New Issue
Block a user