@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhortuneAccountEmailRotateController
4 extends PhortuneAccountController {
5
6 protected function shouldRequireAccountEditCapability() {
7 return true;
8 }
9
10 protected function handleAccountRequest(AphrontRequest $request) {
11 $viewer = $this->getViewer();
12 $account = $this->getAccount();
13
14 $address = id(new PhortuneAccountEmailQuery())
15 ->setViewer($viewer)
16 ->withAccountPHIDs(array($account->getPHID()))
17 ->withIDs(array($request->getURIData('addressID')))
18 ->requireCapabilities(
19 array(
20 PhabricatorPolicyCapability::CAN_VIEW,
21 PhabricatorPolicyCapability::CAN_EDIT,
22 ))
23 ->executeOne();
24 if (!$address) {
25 return new Aphront404Response();
26 }
27
28 $address_uri = $address->getURI();
29
30 if ($request->isFormOrHisecPost()) {
31 $xactions = array();
32
33 $xactions[] = $address->getApplicationTransactionTemplate()
34 ->setTransactionType(
35 PhortuneAccountEmailRotateTransaction::TRANSACTIONTYPE)
36 ->setNewValue(true);
37
38 $address->getApplicationTransactionEditor()
39 ->setActor($viewer)
40 ->setContentSourceFromRequest($request)
41 ->setContinueOnMissingFields(true)
42 ->setContinueOnNoEffect(true)
43 ->setCancelURI($address_uri)
44 ->applyTransactions($address, $xactions);
45
46 return id(new AphrontRedirectResponse())->setURI($address_uri);
47 }
48
49 return $this->newDialog()
50 ->setTitle(pht('Rotate Access Key'))
51 ->appendParagraph(
52 pht(
53 'Rotate the access key for email address %s?',
54 phutil_tag('strong', array(), $address->getAddress())))
55 ->appendParagraph(
56 pht(
57 'Existing access links which have been sent to this email address '.
58 'will stop working.'))
59 ->addSubmitButton(pht('Rotate Access Key'))
60 ->addCancelButton($address_uri);
61 }
62}