mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
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:
parent
7b61cb3163
commit
d10d29e590
3 changed files with 1 additions and 23 deletions
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue