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

Use custom socialaccount adapter to accommodate LDAP backend

The LDAP backend does not set a usable password in Django, which
triggers a saftey net in allauth when trying to disconnect the last
social auth method.
parent 96edb165
No related branches found
No related tags found
1 merge request!413Resolve "User registration"
Pipeline #5375 failed
"""Helpers/overrides for django-allauth."""
from django.conf import settings
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
class OurSocialAccountAdapter(DefaultSocialAccountAdapter):
"""Customised adapter that recognises other authentication mechanisms."""
def validate_disconnect(self, account, accounts):
"""Validate whether or not the socialaccount account can be safely disconnected.
Honours other authentication backends, i.e. ignores unusable passwords if LDAP is used.
"""
if "django_auth_ldap.backend.LDAPBackend" in settings.AUTHENTICATION_BACKENDS:
# Ignore upstream validation error as we do not need a usable password
return None
# Let upstream decide whether we can disconnect or not
return super().validate_disconnect(account, accounts)
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