Path: blob/master/src/applications/auth/controller/PhabricatorAuthValidateController.php
12256 views
<?php12final class PhabricatorAuthValidateController3extends PhabricatorAuthController {45public function shouldRequireLogin() {6return false;7}89public function shouldAllowPartialSessions() {10return true;11}1213public function shouldAllowLegallyNonCompliantUsers() {14return true;15}1617public function handleRequest(AphrontRequest $request) {18$viewer = $this->getViewer();1920$failures = array();2122if (!strlen($request->getStr('expect'))) {23return $this->renderErrors(24array(25pht(26'Login validation is missing expected parameter ("%s").',27'phusr'),28));29}3031$expect_phusr = $request->getStr('expect');32$actual_phusr = $request->getCookie(PhabricatorCookies::COOKIE_USERNAME);33if ($actual_phusr != $expect_phusr) {34if ($actual_phusr) {35$failures[] = pht(36"Attempted to set '%s' cookie to '%s', but your browser sent back ".37"a cookie with the value '%s'. Clear your browser's cookies and ".38"try again.",39'phusr',40$expect_phusr,41$actual_phusr);42} else {43$failures[] = pht(44"Attempted to set '%s' cookie to '%s', but your browser did not ".45"accept the cookie. Check that cookies are enabled, clear them, ".46"and try again.",47'phusr',48$expect_phusr);49}50}5152if (!$failures) {53if (!$viewer->getPHID()) {54$failures[] = pht(55'Login cookie was set correctly, but your login session is not '.56'valid. Try clearing cookies and logging in again.');57}58}5960if ($failures) {61return $this->renderErrors($failures);62}6364$finish_uri = $this->getApplicationURI('finish/');65return id(new AphrontRedirectResponse())->setURI($finish_uri);66}6768private function renderErrors(array $messages) {69return $this->renderErrorPage(70pht('Login Failure'),71$messages);72}7374}757677