Do not enable the create part from provider permission automatically

This allows users to create new datastructures, which is maybe not wanted. Besides it has to be configured first.
This commit is contained in:
Jan Böhmer 2023-07-17 00:20:38 +02:00
parent 7b61cb3163
commit d10d29e590
3 changed files with 1 additions and 23 deletions

View file

@ -43,7 +43,7 @@ final class PermissionData implements \JsonSerializable
/**
* The current schema version of the permission data
*/
public const CURRENT_SCHEMA_VERSION = 3;
public const CURRENT_SCHEMA_VERSION = 2;
/**
* Creates a new Permission Data Instance using the given data.

View file

@ -138,13 +138,4 @@ class PermissionSchemaUpdater
$holder->getPermissions()->removePermission('devices');
}
}
private function upgradeSchemaToVersion3(HasPermissionsInterface $holder): void //@phpstan-ignore-line This is called via reflection
{
//If the info_providers permissions are not defined yet, set it if the user can create parts
if (!$holder->getPermissions()->isAnyOperationOfPermissionSet('info_providers')) {
$user_can_create_parts = $holder->getPermissions()->getPermissionValue('parts', 'create');
$holder->getPermissions()->setPermissionValue('info_providers', 'create_parts', $user_can_create_parts);
}
}
}

View file

@ -110,17 +110,4 @@ class PermissionSchemaUpdaterTest extends WebTestCase
self::assertEquals(PermissionData::INHERIT, $user->getPermissions()->getPermissionValue('projects', 'edit'));
self::assertEquals(PermissionData::DISALLOW, $user->getPermissions()->getPermissionValue('projects', 'delete'));
}
public function testUpgradeSchemaToVersion3(): void
{
$perm_data = new PermissionData();
$perm_data->setSchemaVersion(2);
$perm_data->setPermissionValue('parts', 'create', PermissionData::ALLOW);
$user = new TestPermissionHolder($perm_data);
//After the upgrade the user should be allowed to create parts from info providers
self::assertTrue($this->service->upgradeSchema($user, 3));
self::assertEquals(PermissionData::ALLOW, $user->getPermissions()->getPermissionValue('info_providers', 'create_parts'));
}
}