Skip to content
Commits on Source (1)
  • Reiter, Christoph's avatar
    Remove roles · e9590b40
    Reiter, Christoph authored
    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".
    e9590b40
......@@ -42,12 +42,6 @@ trait PersonTrait
*/
private $email;
/**
* @var array
* @Groups({"BasePerson:current-user"})
*/
private $roles;
/**
* @var string
* @ApiProperty(iri="http://schema.org/birthDate")
......@@ -63,7 +57,6 @@ trait PersonTrait
public function __construct()
{
$this->extraData = [];
$this->roles = [];
}
public function setIdentifier(string $identifier)
......@@ -125,16 +118,6 @@ trait PersonTrait
return $this->extraData[$key] ?? null;
}
public function getRoles(): array
{
return $this->roles;
}
public function setRoles(array $roles)
{
$this->roles = $roles;
}
public function getBirthDate(): ?string
{
return $this->birthDate;
......
......@@ -63,21 +63,4 @@ class DummyPersonProvider implements PersonProviderInterface
{
$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
{
$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
{
$person = new Person();
$person->setIdentifier($user->getUserIdentifier());
$person->setRoles($user->getRoles());
$personProvider = new DummyPersonProvider($person);
$container = $client->getContainer();
$container->set('test.PersonProviderInterface', $personProvider);
......@@ -79,18 +78,6 @@ class ExtTest extends ApiTestCase
$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()
{
$client = self::createClient();
......
......@@ -21,10 +21,4 @@ class PersonTest extends TestCase
$this->assertSame(null, $person->getExtraData('nope'));
}
public function testRoles()
{
$person = new Person();
$this->assertSame([], $person->getRoles());
}
}