token = $data['token']; } public function processRequest() { $request = $this->getRequest(); if (!PhabricatorEnv::getEnvConfig('auth.password-auth-enabled')) { return new Aphront400Response(); } if ($request->getUser()->getPHID()) { $view = new AphrontRequestFailureView(); $view->setHeader('Already Logged In'); $view->appendChild( '

You are already logged in.

'); $view->appendChild( '
'. 'Return Home'. '
'); return $this->buildStandardPageResponse( $view, array( 'title' => 'Already Logged In', )); } $token = $this->token; $email = $request->getStr('email'); $target_user = id(new PhabricatorUser())->loadOneWhere( 'email = %s', $email); if (!$target_user || !$target_user->validateEmailToken($token)) { $view = new AphrontRequestFailureView(); $view->setHeader('Unable to Login'); $view->appendChild( '

The authentication information in the link you clicked is '. 'invalid or out of date. Make sure you are copy-and-pasting the '. 'entire link into your browser. You can try again, or request '. 'a new email.

'); $view->appendChild( '
'. 'Send Another Email'. '
'); return $this->buildStandardPageResponse( $view, array( 'title' => 'Email Sent', )); } $session_key = $target_user->establishSession('web'); $request->setCookie('phusr', $target_user->getUsername()); $request->setCookie('phsid', $session_key); $uri = new PhutilURI('/login/validate/'); $uri->setQueryParams( array( 'phusr' => $target_user->getUsername(), 'next' => '/login/reset/', )); return id(new AphrontRedirectResponse()) ->setURI((string)$uri); } }