Page MenuHomePhabricator

D13155.diff
No OneTemporary

D13155.diff

diff --git a/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php
--- a/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php
+++ b/src/aphront/configuration/AphrontDefaultApplicationConfiguration.php
@@ -164,14 +164,6 @@
return $login_controller->handleRequest($request);
}
- $list = $ex->getMoreInfo();
- foreach ($list as $key => $item) {
- $list[$key] = phutil_tag('li', array(), $item);
- }
- if ($list) {
- $list = phutil_tag('ul', array(), $list);
- }
-
$content = array(
phutil_tag(
'div',
@@ -179,17 +171,28 @@
'class' => 'aphront-policy-rejection',
),
$ex->getRejection()),
- phutil_tag(
+ );
+
+ if ($ex->getCapabilityName()) {
+ $list = $ex->getMoreInfo();
+ foreach ($list as $key => $item) {
+ $list[$key] = phutil_tag('li', array(), $item);
+ }
+ if ($list) {
+ $list = phutil_tag('ul', array(), $list);
+ }
+
+ $content[] = phutil_tag(
'div',
array(
'class' => 'aphront-capability-details',
),
- pht('Users with the "%s" capability:', $ex->getCapabilityName())),
- $list,
- );
+ pht('Users with the "%s" capability:', $ex->getCapabilityName()));
- $dialog = new AphrontDialogView();
- $dialog
+ $content[] = $list;
+ }
+
+ $dialog = id(new AphrontDialogView())
->setTitle($ex->getTitle())
->setClass('aphront-access-dialog')
->setUser($user)
diff --git a/src/applications/policy/filter/PhabricatorPolicyFilter.php b/src/applications/policy/filter/PhabricatorPolicyFilter.php
--- a/src/applications/policy/filter/PhabricatorPolicyFilter.php
+++ b/src/applications/policy/filter/PhabricatorPolicyFilter.php
@@ -547,35 +547,17 @@
$details = array_filter(array_merge(array($more), (array)$exceptions));
- // NOTE: Not every type of policy object has a real PHID; just load an
- // empty handle if a real PHID isn't available.
- $phid = nonempty($object->getPHID(), PhabricatorPHIDConstants::PHID_VOID);
-
- $handle = id(new PhabricatorHandleQuery())
- ->setViewer($this->viewer)
- ->withPHIDs(array($phid))
- ->executeOne();
-
- $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
- if ($is_serious) {
- $title = pht(
- 'Access Denied: %s',
- $handle->getObjectName());
- } else {
- $title = pht(
- 'You Shall Not Pass: %s',
- $handle->getObjectName());
- }
+ $access_denied = $this->renderAccessDenied($object);
$full_message = pht(
'[%s] (%s) %s // %s',
- $title,
+ $access_denied,
$capability_name,
$rejection,
implode(' ', $details));
$exception = id(new PhabricatorPolicyException($full_message))
- ->setTitle($title)
+ ->setTitle($access_denied)
->setRejection($rejection)
->setCapabilityName($capability_name)
->setMoreInfo($details);
@@ -668,4 +650,30 @@
}
}
+ private function renderAccessDenied(PhabricatorPolicyInterface $object) {
+ // NOTE: Not every type of policy object has a real PHID; just load an
+ // empty handle if a real PHID isn't available.
+ $phid = nonempty($object->getPHID(), PhabricatorPHIDConstants::PHID_VOID);
+
+ $handle = id(new PhabricatorHandleQuery())
+ ->setViewer($this->viewer)
+ ->withPHIDs(array($phid))
+ ->executeOne();
+
+ $object_name = $handle->getObjectName();
+
+ $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
+ if ($is_serious) {
+ $access_denied = pht(
+ 'Access Denied: %s',
+ $object_name);
+ } else {
+ $access_denied = pht(
+ 'You Shall Not Pass: %s',
+ $object_name);
+ }
+
+ return $access_denied;
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Mon, May 20, 4:37 AM (3 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6285140
Default Alt Text
D13155.diff (3 KB)

Event Timeline