Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/auth/controller/PhabricatorAuthConfirmLinkController.php
12256 views
1
<?php
2
3
final class PhabricatorAuthConfirmLinkController
4
extends PhabricatorAuthController {
5
6
public function handleRequest(AphrontRequest $request) {
7
$viewer = $this->getViewer();
8
$accountkey = $request->getURIData('akey');
9
10
$result = $this->loadAccountForRegistrationOrLinking($accountkey);
11
list($account, $provider, $response) = $result;
12
13
if ($response) {
14
return $response;
15
}
16
17
if (!$provider->shouldAllowAccountLink()) {
18
return $this->renderError(pht('This account is not linkable.'));
19
}
20
21
$panel_uri = '/settings/panel/external/';
22
23
if ($request->isFormOrHisecPost()) {
24
$workflow_key = sprintf(
25
'account.link(%s)',
26
$account->getPHID());
27
28
$hisec_token = id(new PhabricatorAuthSessionEngine())
29
->setWorkflowKey($workflow_key)
30
->requireHighSecurityToken($viewer, $request, $panel_uri);
31
32
$account->setUserPHID($viewer->getPHID());
33
$account->save();
34
35
$this->clearRegistrationCookies();
36
37
// TODO: Send the user email about the new account link.
38
39
return id(new AphrontRedirectResponse())->setURI($panel_uri);
40
}
41
42
$dialog = $this->newDialog()
43
->setTitle(pht('Confirm %s Account Link', $provider->getProviderName()))
44
->addCancelButton($panel_uri)
45
->addSubmitButton(pht('Confirm Account Link'));
46
47
$form = id(new PHUIFormLayoutView())
48
->setFullWidth(true)
49
->appendChild(
50
phutil_tag(
51
'div',
52
array(
53
'class' => 'aphront-form-instructions',
54
),
55
pht(
56
'Confirm the link with this %s account. This account will be '.
57
'able to log in to your %s account.',
58
$provider->getProviderName(),
59
PlatformSymbols::getPlatformServerName())))
60
->appendChild(
61
id(new PhabricatorAuthAccountView())
62
->setUser($viewer)
63
->setExternalAccount($account)
64
->setAuthProvider($provider));
65
66
$dialog->appendChild($form);
67
68
$crumbs = $this->buildApplicationCrumbs();
69
$crumbs->addTextCrumb(pht('Confirm Link'), $panel_uri);
70
$crumbs->addTextCrumb($provider->getProviderName());
71
$crumbs->setBorder(true);
72
73
return $this->newPage()
74
->setTitle(pht('Confirm External Account Link'))
75
->setCrumbs($crumbs)
76
->appendChild($dialog);
77
}
78
79
80
}
81
82