Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15442359
D13155.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D13155.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 27, 10:57 PM (4 w, 18 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7706234
Default Alt Text
D13155.diff (3 KB)
Attached To
Mode
D13155: Make policy violation dialog more flexible
Attached
Detach File
Event Timeline
Log In to Comment