@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
3abstract class PhabricatorEditEngineMFAEngine
4 extends Phobject {
5
6 private $object;
7 private $viewer;
8
9 public function setObject(PhabricatorEditEngineMFAInterface $object) {
10 $this->object = $object;
11 return $this;
12 }
13
14 public function getObject() {
15 return $this->object;
16 }
17
18 public function setViewer(PhabricatorUser $viewer) {
19 $this->viewer = $viewer;
20 return $this;
21 }
22
23 public function getViewer() {
24 if (!$this->viewer) {
25 throw new PhutilInvalidStateException('setViewer');
26 }
27
28 return $this->viewer;
29 }
30
31 final public static function newEngineForObject(
32 PhabricatorEditEngineMFAInterface $object) {
33 return $object->newEditEngineMFAEngine()
34 ->setObject($object);
35 }
36
37 /**
38 * Do edits to this object REQUIRE that the user submit MFA?
39 *
40 * This is a strict requirement: users will need to add MFA to their accounts
41 * if they don't already have it.
42 *
43 * @return bool True to strictly require MFA.
44 */
45 public function shouldRequireMFA() {
46 return false;
47 }
48
49 /**
50 * Should edits to this object prompt for MFA if it's available?
51 *
52 * This is advisory: users without MFA on their accounts will be able to
53 * perform edits without being required to add MFA.
54 *
55 * @return bool True to prompt for MFA if available.
56 */
57 public function shouldTryMFA() {
58 return false;
59 }
60
61}