From 38c48ae7d048e0858de7358b48c7e6744014c2f5 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 18 Dec 2018 11:31:45 -0800 Subject: [PATCH] Remove support for the "TYPE_AUTH_WILLLOGIN" event Summary: Depends on D19903. Ref T13222. This was a Facebook-specific thing from D6202 that I believe no other install ever used, and I'm generally trying to move away from the old "event" system (the more modern modular/engine patterns generally replace it). Just drop support for this. Since the constant is being removed, anything that's actually using it should break in an obvious way, and I'll note this in the changelog. There's no explicit replacement but I don't think this hook is useful for anything except "being Facebook in 2013". Test Plan: - Grepped for `TYPE_AUTH_WILLLOGIN`. - Logged in. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13222 Differential Revision: https://secure.phabricator.com/D19904 --- .../controller/PhabricatorAuthController.php | 57 +++++++------------ .../events/constant/PhabricatorEventType.php | 1 - 2 files changed, 21 insertions(+), 37 deletions(-) diff --git a/src/applications/auth/controller/PhabricatorAuthController.php b/src/applications/auth/controller/PhabricatorAuthController.php index 4d7644e2d1..9b7267ec96 100644 --- a/src/applications/auth/controller/PhabricatorAuthController.php +++ b/src/applications/auth/controller/PhabricatorAuthController.php @@ -55,44 +55,29 @@ abstract class PhabricatorAuthController extends PhabricatorController { $response = $this->buildLoginValidateResponse($user); $session_type = PhabricatorAuthSession::TYPE_WEB; - $event_type = PhabricatorEventType::TYPE_AUTH_WILLLOGINUSER; - $event_data = array( - 'user' => $user, - 'type' => $session_type, - 'response' => $response, - 'shouldLogin' => true, - ); - - $event = id(new PhabricatorEvent($event_type, $event_data)) - ->setUser($user); - PhutilEventEngine::dispatchEvent($event); - - $should_login = $event->getValue('shouldLogin'); - if ($should_login) { - if ($force_full_session) { - $partial_session = false; - } else { - $partial_session = true; - } - - $session_key = id(new PhabricatorAuthSessionEngine()) - ->establishSession($session_type, $user->getPHID(), $partial_session); - - // NOTE: We allow disabled users to login and roadblock them later, so - // there's no check for users being disabled here. - - $request = $this->getRequest(); - $request->setCookie( - PhabricatorCookies::COOKIE_USERNAME, - $user->getUsername()); - $request->setCookie( - PhabricatorCookies::COOKIE_SESSION, - $session_key); - - $this->clearRegistrationCookies(); + if ($force_full_session) { + $partial_session = false; + } else { + $partial_session = true; } - return $event->getValue('response'); + $session_key = id(new PhabricatorAuthSessionEngine()) + ->establishSession($session_type, $user->getPHID(), $partial_session); + + // NOTE: We allow disabled users to login and roadblock them later, so + // there's no check for users being disabled here. + + $request = $this->getRequest(); + $request->setCookie( + PhabricatorCookies::COOKIE_USERNAME, + $user->getUsername()); + $request->setCookie( + PhabricatorCookies::COOKIE_SESSION, + $session_key); + + $this->clearRegistrationCookies(); + + return $response; } protected function clearRegistrationCookies() { diff --git a/src/infrastructure/events/constant/PhabricatorEventType.php b/src/infrastructure/events/constant/PhabricatorEventType.php index c92503376b..3dea7b36e6 100644 --- a/src/infrastructure/events/constant/PhabricatorEventType.php +++ b/src/infrastructure/events/constant/PhabricatorEventType.php @@ -22,7 +22,6 @@ final class PhabricatorEventType extends PhutilEventType { const TYPE_PEOPLE_DIDRENDERMENU = 'people.didRenderMenu'; const TYPE_AUTH_WILLREGISTERUSER = 'auth.willRegisterUser'; - const TYPE_AUTH_WILLLOGINUSER = 'auth.willLoginUser'; const TYPE_AUTH_DIDVERIFYEMAIL = 'auth.didVerifyEmail'; }