@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 PhabricatorAuthMFAEditEngineExtension
4 extends PhabricatorEditEngineExtension {
5
6 const EXTENSIONKEY = 'auth.mfa';
7 const FIELDKEY = 'mfa';
8
9 public function getExtensionPriority() {
10 return 12000;
11 }
12
13 public function isExtensionEnabled() {
14 return true;
15 }
16
17 public function getExtensionName() {
18 return pht('MFA');
19 }
20
21 public function supportsObject(
22 PhabricatorEditEngine $engine,
23 PhabricatorApplicationTransactionInterface $object) {
24 return true;
25 }
26
27 public function buildCustomEditFields(
28 PhabricatorEditEngine $engine,
29 PhabricatorApplicationTransactionInterface $object) {
30
31 $mfa_type = PhabricatorTransactions::TYPE_MFA;
32
33 $viewer = $engine->getViewer();
34
35 $mfa_field = id(new PhabricatorApplyEditField())
36 ->setViewer($viewer)
37 ->setKey(self::FIELDKEY)
38 ->setLabel(pht('MFA'))
39 ->setIsFormField(false)
40 ->setCommentActionLabel(pht('Sign With MFA'))
41 ->setCanApplyWithoutEditCapability(true)
42 ->setCommentActionOrder(12000)
43 ->setActionDescription(
44 pht('You will be prompted to provide MFA when you submit.'))
45 ->setDescription(pht('Sign this transaction group with MFA.'))
46 ->setConduitTypeDescription(
47 pht('True to sign this transaction group with MFA.'))
48 ->setTransactionType($mfa_type);
49
50 return array(
51 $mfa_field,
52 );
53 }
54
55}