Skip to content
Snippets Groups Projects
Commit 66d244f0 authored by Nik | Klampfradler's avatar Nik | Klampfradler Committed by Tom Teichler
Browse files

Only fail auth for non-LDAP users if password handling is enabled

parent 7d022176
No related branches found
No related tags found
1 merge request!501Resolve "Allow using Django-local accounts in addition to LDAP accounts"
......@@ -20,13 +20,13 @@ class LDAPBackend(_LDAPBackend):
Django database in order to not require it to have global admin permissions
on the LDAP directory.
"""
user = ldap_user.authenticate(password)
if not user:
# Fail early and do not try other backends
raise PermissionDenied("LDAP failed to authenticate user")
user = super().authenticate_ldap_user(ldap_user, password)
if self.settings.SET_USABLE_PASSWORD:
if not user:
# Fail early and do not try other backends
raise PermissionDenied("LDAP failed to authenticate user")
# Set a usable password so users can change their LDAP password
user.set_password(password)
user.save()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment