From 6fd2f685fe5722326a7719892368d0fa2aa92efa Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 15 Apr 2016 11:17:18 +0100 Subject: [PATCH] Simplify _check_password --- synapse/handlers/auth.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/synapse/handlers/auth.py b/synapse/handlers/auth.py index 916632c7d..61fe56032 100644 --- a/synapse/handlers/auth.py +++ b/synapse/handlers/auth.py @@ -432,11 +432,15 @@ class AuthHandler(BaseHandler): Returns: True if the user_id successfully authenticated """ - defer.returnValue(( - (yield self._check_ldap_password(user_id, password)) - or - (yield self._check_local_password(user_id, password)) - )) + valid_ldap = yield self._check_ldap_password(user_id, password) + if valid_ldap: + defer.returnValue(True) + + valid_local_password = yield self._check_local_password(user_id, password) + if valid_local_password: + defer.returnValue(True) + + defer.returnValue(False) @defer.inlineCallbacks def _check_local_password(self, user_id, password):