Path: blob/master/src/applications/auth/controller/PhabricatorAuthConfirmLinkController.php
12256 views
<?php12final class PhabricatorAuthConfirmLinkController3extends PhabricatorAuthController {45public function handleRequest(AphrontRequest $request) {6$viewer = $this->getViewer();7$accountkey = $request->getURIData('akey');89$result = $this->loadAccountForRegistrationOrLinking($accountkey);10list($account, $provider, $response) = $result;1112if ($response) {13return $response;14}1516if (!$provider->shouldAllowAccountLink()) {17return $this->renderError(pht('This account is not linkable.'));18}1920$panel_uri = '/settings/panel/external/';2122if ($request->isFormOrHisecPost()) {23$workflow_key = sprintf(24'account.link(%s)',25$account->getPHID());2627$hisec_token = id(new PhabricatorAuthSessionEngine())28->setWorkflowKey($workflow_key)29->requireHighSecurityToken($viewer, $request, $panel_uri);3031$account->setUserPHID($viewer->getPHID());32$account->save();3334$this->clearRegistrationCookies();3536// TODO: Send the user email about the new account link.3738return id(new AphrontRedirectResponse())->setURI($panel_uri);39}4041$dialog = $this->newDialog()42->setTitle(pht('Confirm %s Account Link', $provider->getProviderName()))43->addCancelButton($panel_uri)44->addSubmitButton(pht('Confirm Account Link'));4546$form = id(new PHUIFormLayoutView())47->setFullWidth(true)48->appendChild(49phutil_tag(50'div',51array(52'class' => 'aphront-form-instructions',53),54pht(55'Confirm the link with this %s account. This account will be '.56'able to log in to your %s account.',57$provider->getProviderName(),58PlatformSymbols::getPlatformServerName())))59->appendChild(60id(new PhabricatorAuthAccountView())61->setUser($viewer)62->setExternalAccount($account)63->setAuthProvider($provider));6465$dialog->appendChild($form);6667$crumbs = $this->buildApplicationCrumbs();68$crumbs->addTextCrumb(pht('Confirm Link'), $panel_uri);69$crumbs->addTextCrumb($provider->getProviderName());70$crumbs->setBorder(true);7172return $this->newPage()73->setTitle(pht('Confirm External Account Link'))74->setCrumbs($crumbs)75->appendChild($dialog);76}777879}808182