Skip to content
Snippets Groups Projects
Commit e9590b40 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

Remove roles

The roles have moved to the frontend bundle for now, which makes
them work for all API users, not jsut the ones that have a Person object
associated.

In the future we also don't want to expose the roles directly but
add one more layer, some kind of API "capabilities".
parent b402c3c4
No related branches found
No related tags found
No related merge requests found
Pipeline #58791 passed
...@@ -42,12 +42,6 @@ trait PersonTrait ...@@ -42,12 +42,6 @@ trait PersonTrait
*/ */
private $email; private $email;
/**
* @var array
* @Groups({"BasePerson:current-user"})
*/
private $roles;
/** /**
* @var string * @var string
* @ApiProperty(iri="http://schema.org/birthDate") * @ApiProperty(iri="http://schema.org/birthDate")
...@@ -63,7 +57,6 @@ trait PersonTrait ...@@ -63,7 +57,6 @@ trait PersonTrait
public function __construct() public function __construct()
{ {
$this->extraData = []; $this->extraData = [];
$this->roles = [];
} }
public function setIdentifier(string $identifier) public function setIdentifier(string $identifier)
...@@ -125,16 +118,6 @@ trait PersonTrait ...@@ -125,16 +118,6 @@ trait PersonTrait
return $this->extraData[$key] ?? null; return $this->extraData[$key] ?? null;
} }
public function getRoles(): array
{
return $this->roles;
}
public function setRoles(array $roles)
{
$this->roles = $roles;
}
public function getBirthDate(): ?string public function getBirthDate(): ?string
{ {
return $this->birthDate; return $this->birthDate;
......
...@@ -63,21 +63,4 @@ class DummyPersonProvider implements PersonProviderInterface ...@@ -63,21 +63,4 @@ class DummyPersonProvider implements PersonProviderInterface
{ {
$this->currentIdentifier = $identifier; $this->currentIdentifier = $identifier;
} }
public function getRolesForCurrentPerson(): array
{
if ($this->currentIdentifier === null) {
return [];
}
return $this->getCurrentPerson()->getRoles();
}
public function setRolesForCurrentPerson(array $roles): void
{
if ($this->currentIdentifier === null) {
return;
}
$this->getCurrentPerson()->setRoles($roles);
}
} }
...@@ -52,14 +52,4 @@ class DummyPersonProvider implements PersonProviderInterface ...@@ -52,14 +52,4 @@ class DummyPersonProvider implements PersonProviderInterface
{ {
$this->person->setIdentifier($identifier); $this->person->setIdentifier($identifier);
} }
public function getRolesForCurrentPerson(): array
{
return $this->person->getRoles();
}
public function setRolesForCurrentPerson(array $roles): void
{
$this->person->setRoles($roles);
}
} }
...@@ -20,7 +20,6 @@ class ExtTest extends ApiTestCase ...@@ -20,7 +20,6 @@ class ExtTest extends ApiTestCase
{ {
$person = new Person(); $person = new Person();
$person->setIdentifier($user->getUserIdentifier()); $person->setIdentifier($user->getUserIdentifier());
$person->setRoles($user->getRoles());
$personProvider = new DummyPersonProvider($person); $personProvider = new DummyPersonProvider($person);
$container = $client->getContainer(); $container = $client->getContainer();
$container->set('test.PersonProviderInterface', $personProvider); $container->set('test.PersonProviderInterface', $personProvider);
...@@ -79,18 +78,6 @@ class ExtTest extends ApiTestCase ...@@ -79,18 +78,6 @@ class ExtTest extends ApiTestCase
$this->assertArrayHasKey('etag', $header); $this->assertArrayHasKey('etag', $header);
} }
public function testGetPersonRoles()
{
$client = $this->withUser('foobar', ['ROLE'], '42');
$user = $this->getUser($client);
$this->withPerson($client, $user);
$response = $client->request('GET', '/base/people/foobar', ['headers' => [
'Authorization' => 'Bearer 42',
]]);
$data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR);
$this->assertEquals(['ROLE'], $data['roles']);
}
public function testAuthChecks() public function testAuthChecks()
{ {
$client = self::createClient(); $client = self::createClient();
......
...@@ -21,10 +21,4 @@ class PersonTest extends TestCase ...@@ -21,10 +21,4 @@ class PersonTest extends TestCase
$this->assertSame(null, $person->getExtraData('nope')); $this->assertSame(null, $person->getExtraData('nope'));
} }
public function testRoles()
{
$person = new Person();
$this->assertSame([], $person->getRoles());
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment