Page MenuHomePhorge

T15443
ActivePublic

Authored by aklapper on Jun 3 2023, 12:06.
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
index 3d8570b4f7..efebb42f48 100644
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -4622,6 +4622,7 @@ phutil_register_library_map(array(
'PhabricatorRepositoryIdentity' => 'applications/repository/storage/PhabricatorRepositoryIdentity.php',
'PhabricatorRepositoryIdentityAssignTransaction' => 'applications/repository/xaction/PhabricatorRepositoryIdentityAssignTransaction.php',
'PhabricatorRepositoryIdentityChangeWorker' => 'applications/repository/worker/PhabricatorRepositoryIdentityChangeWorker.php',
+ 'PhabricatorRepositoryIdentityEditCapability' => 'applications/repository/capability/PhabricatorRepositoryIdentityEditCapability.php',
'PhabricatorRepositoryIdentityEditEngine' => 'applications/repository/engine/PhabricatorRepositoryIdentityEditEngine.php',
'PhabricatorRepositoryIdentityFerretEngine' => 'applications/repository/search/PhabricatorRepositoryIdentityFerretEngine.php',
'PhabricatorRepositoryIdentityPHIDType' => 'applications/repository/phid/PhabricatorRepositoryIdentityPHIDType.php',
@@ -11313,6 +11314,7 @@ phutil_register_library_map(array(
),
'PhabricatorRepositoryIdentityAssignTransaction' => 'PhabricatorRepositoryIdentityTransactionType',
'PhabricatorRepositoryIdentityChangeWorker' => 'PhabricatorWorker',
+ 'PhabricatorRepositoryIdentityEditCapability' => 'PhabricatorPolicyCapability',
'PhabricatorRepositoryIdentityEditEngine' => 'PhabricatorEditEngine',
'PhabricatorRepositoryIdentityFerretEngine' => 'PhabricatorFerretEngine',
'PhabricatorRepositoryIdentityPHIDType' => 'PhabricatorPHIDType',
diff --git a/src/applications/diffusion/application/PhabricatorDiffusionApplication.php b/src/applications/diffusion/application/PhabricatorDiffusionApplication.php
index e0e74486da..fc349c8896 100644
--- a/src/applications/diffusion/application/PhabricatorDiffusionApplication.php
+++ b/src/applications/diffusion/application/PhabricatorDiffusionApplication.php
@@ -183,6 +183,9 @@ final class PhabricatorDiffusionApplication extends PhabricatorApplication {
DiffusionCreateRepositoriesCapability::CAPABILITY => array(
'default' => PhabricatorPolicies::POLICY_ADMIN,
),
+ PhabricatorRepositoryIdentityEditCapability::CAPABILITY => array(
+ 'default' => PhabricatorPolicies::POLICY_USER,
+ ),
);
}
diff --git a/src/applications/repository/capability/PhabricatorRepositoryIdentityEditCapability.php b/src/applications/repository/capability/PhabricatorRepositoryIdentityEditCapability.php
new file mode 100644
index 0000000000..aa53163e70
--- /dev/null
+++ b/src/applications/repository/capability/PhabricatorRepositoryIdentityEditCapability.php
@@ -0,0 +1,16 @@
+<?php
+
+final class PhabricatorRepositoryIdentityEditCapability
+ extends PhabricatorPolicyCapability {
+
+ const CAPABILITY = 'repository.identity.create';
+
+ public function getCapabilityName() {
+ return pht('Can Create and Edit Identities');
+ }
+
+ public function describeCapabilityRejection() {
+ return pht('You do not have permission to create or edit identities.');
+ }
+
+}
diff --git a/src/applications/repository/engine/PhabricatorRepositoryIdentityEditEngine.php b/src/applications/repository/engine/PhabricatorRepositoryIdentityEditEngine.php
index 742e4a159f..20fc6313cc 100644
--- a/src/applications/repository/engine/PhabricatorRepositoryIdentityEditEngine.php
+++ b/src/applications/repository/engine/PhabricatorRepositoryIdentityEditEngine.php
@@ -70,7 +70,8 @@ final class PhabricatorRepositoryIdentityEditEngine
}
protected function getCreateNewObjectPolicy() {
- return PhabricatorPolicies::POLICY_USER;
+ return $this->getApplication()->getPolicy(
+ PhabricatorRepositoryIdentityEditCapability::CAPABILITY);
}
protected function buildCustomEditFields($object) {

Event Timeline

<bikeshedding>

+    return pht('Can Create and Edit Identities');

Shouldn't Create and Edit be lowercase?
</bikeshedding>

In P13#202, @smith wrote:

Shouldn't Create and Edit be lowercase?

No, all other Policy strings also use Title Case.