From 7d11dca14fb171b33fbaa425cedbb55c746545ab Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Thu, 12 Sep 2013 15:48:11 +0200 Subject: get_bound_ldapuser(): support custom username. --- okupy/common/ldap_helpers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/okupy/common/ldap_helpers.py b/okupy/common/ldap_helpers.py index 43f3e3e..69cacbf 100644 --- a/okupy/common/ldap_helpers.py +++ b/okupy/common/ldap_helpers.py @@ -9,13 +9,14 @@ from okupy.accounts.models import LDAPUser from okupy.crypto.ciphers import cipher -def get_bound_ldapuser(request, password=None): +def get_bound_ldapuser(request, password=None, username=None): """ Get LDAPUser with connection bound to the current user. Uses either provided password or the secondary password saved in session. """ - username = request.user.username + if not username: + username = request.user.username if not password: try: password = b64encode(cipher.decrypt( -- cgit v1.2.3-65-gdbad