From 798345424e1c852b0d37e06a5a2de3f9c3b5816f Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Thu, 12 Sep 2013 15:32:20 +0200 Subject: Clean up settings.DATABASES when get_bound_ldapuser() fails. For example, if invalid credentials are provided. --- okupy/common/ldap_helpers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'okupy') diff --git a/okupy/common/ldap_helpers.py b/okupy/common/ldap_helpers.py index 5b3e76a..43f3e3e 100644 --- a/okupy/common/ldap_helpers.py +++ b/okupy/common/ldap_helpers.py @@ -29,7 +29,11 @@ def get_bound_ldapuser(request, password=None): username=username, password=password, ) - return bound_cls.objects.get(username=username) + try: + return bound_cls.objects.get(username=username) + except Exception as e: + bound_cls.restore_alias() + raise e def set_secondary_password(request, password): -- cgit v1.2.3-65-gdbad