diff --git a/src/applications/auth/provider/PhabricatorAuthProviderLDAP.php b/src/applications/auth/provider/PhabricatorAuthProviderLDAP.php index fb69da7a97..1c9844a34f 100644 --- a/src/applications/auth/provider/PhabricatorAuthProviderLDAP.php +++ b/src/applications/auth/provider/PhabricatorAuthProviderLDAP.php @@ -150,25 +150,27 @@ final class PhabricatorAuthProviderLDAP return array($account, $response); } - try { - if (strlen($username) && $has_password) { - $adapter = $this->getAdapter(); - $adapter->setLoginUsername($username); - $adapter->setLoginPassword($password); + if ($request->isFormPost()) { + try { + if (strlen($username) && $has_password) { + $adapter = $this->getAdapter(); + $adapter->setLoginUsername($username); + $adapter->setLoginPassword($password); - // TODO: This calls ldap_bind() eventually, which dumps cleartext - // passwords to the error log. See note in PhutilAuthAdapterLDAP. - // See T3351. + // TODO: This calls ldap_bind() eventually, which dumps cleartext + // passwords to the error log. See note in PhutilAuthAdapterLDAP. + // See T3351. - DarkConsoleErrorLogPluginAPI::enableDiscardMode(); - $account_id = $adapter->getAccountID(); - DarkConsoleErrorLogPluginAPI::disableDiscardMode(); - } else { - throw new Exception("Username and password are required!"); + DarkConsoleErrorLogPluginAPI::enableDiscardMode(); + $account_id = $adapter->getAccountID(); + DarkConsoleErrorLogPluginAPI::disableDiscardMode(); + } else { + throw new Exception("Username and password are required!"); + } + } catch (Exception $ex) { + // TODO: Make this cleaner. + throw $ex; } - } catch (Exception $ex) { - // TODO: Make this cleaner. - throw $ex; } return array($this->loadOrCreateAccount($account_id), $response); diff --git a/src/applications/auth/provider/PhabricatorAuthProviderPassword.php b/src/applications/auth/provider/PhabricatorAuthProviderPassword.php index 7b93fde350..a779df0f2d 100644 --- a/src/applications/auth/provider/PhabricatorAuthProviderPassword.php +++ b/src/applications/auth/provider/PhabricatorAuthProviderPassword.php @@ -163,22 +163,25 @@ final class PhabricatorAuthProviderPassword $account = null; $log_user = null; - if (!$require_captcha || $captcha_valid) { - $username_or_email = $request->getStr('username'); - if (strlen($username_or_email)) { - $user = id(new PhabricatorUser())->loadOneWhere( - 'username = %s', - $username_or_email); + if ($request->isFormPost()) { + if (!$require_captcha || $captcha_valid) { + $username_or_email = $request->getStr('username'); + if (strlen($username_or_email)) { + $user = id(new PhabricatorUser())->loadOneWhere( + 'username = %s', + $username_or_email); - if (!$user) { - $user = PhabricatorUser::loadOneWithEmailAddress($username_or_email); - } + if (!$user) { + $user = PhabricatorUser::loadOneWithEmailAddress( + $username_or_email); + } - if ($user) { - $envelope = new PhutilOpaqueEnvelope($request->getStr('password')); - if ($user->comparePassword($envelope)) { - $account = $this->loadOrCreateAccount($user->getPHID()); - $log_user = $user; + if ($user) { + $envelope = new PhutilOpaqueEnvelope($request->getStr('password')); + if ($user->comparePassword($envelope)) { + $account = $this->loadOrCreateAccount($user->getPHID()); + $log_user = $user; + } } } }