Path: blob/master/src/applications/auth/controller/PhabricatorAuthFinishController.php
12256 views
<?php12final class PhabricatorAuthFinishController3extends 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// If the user already has a full session, just kick them out of here.21$has_partial_session = $viewer->hasSession() &&22$viewer->getSession()->getIsPartial();23if (!$has_partial_session) {24return id(new AphrontRedirectResponse())->setURI('/');25}2627$engine = new PhabricatorAuthSessionEngine();2829// If this cookie is set, the user is headed into a high security area30// after login (normally because of a password reset) so if they are31// able to pass the checkpoint we just want to put their account directly32// into high security mode, rather than prompt them again for the same33// set of credentials.34$jump_into_hisec = $request->getCookie(PhabricatorCookies::COOKIE_HISEC);3536try {37$token = $engine->requireHighSecuritySession(38$viewer,39$request,40'/logout/',41$jump_into_hisec);42} catch (PhabricatorAuthHighSecurityRequiredException $ex) {43$form = id(new PhabricatorAuthSessionEngine())->renderHighSecurityForm(44$ex->getFactors(),45$ex->getFactorValidationResults(),46$viewer,47$request);4849return $this->newDialog()50->setTitle(pht('Provide Multi-Factor Credentials'))51->setShortTitle(pht('Multi-Factor Login'))52->setWidth(AphrontDialogView::WIDTH_FORM)53->addHiddenInput(AphrontRequest::TYPE_HISEC, true)54->appendParagraph(55pht(56'Welcome, %s. To complete the process of logging in, provide your '.57'multi-factor credentials.',58phutil_tag('strong', array(), $viewer->getUsername())))59->appendChild($form->buildLayoutView())60->setSubmitURI($request->getPath())61->addCancelButton($ex->getCancelURI())62->addSubmitButton(pht('Continue'));63}6465// Upgrade the partial session to a full session.66$engine->upgradePartialSession($viewer);6768// TODO: It might be nice to add options like "bind this session to my IP"69// here, even for accounts without multi-factor auth attached to them.7071$next = PhabricatorCookies::getNextURICookie($request);72$request->clearCookie(PhabricatorCookies::COOKIE_NEXTURI);73$request->clearCookie(PhabricatorCookies::COOKIE_HISEC);7475if (!PhabricatorEnv::isValidLocalURIForLink($next)) {76$next = '/';77}7879return id(new AphrontRedirectResponse())->setURI($next);80}8182}838485