1
0
Fork 0
mirror of synced 2024-07-01 04:30:59 +12:00

Update Appwrite to add User labels to Auth roles

This commit is contained in:
Steven Nguyen 2023-05-26 17:40:30 -07:00
parent 078dab38c5
commit 09f3577256
No known key found for this signature in database
2 changed files with 11 additions and 1 deletions

View file

@ -456,6 +456,10 @@ class Auth
}
}
foreach ($user->getAttribute('labels', []) as $label) {
$roles[] = 'label:' . $label;
}
return $roles;
}

View file

@ -352,6 +352,10 @@ class AuthTest extends TestCase
{
$user = new Document([
'$id' => ID::custom('123'),
'labels' => [
'vip',
'admin'
],
'emailVerification' => true,
'phoneVerification' => true,
'memberships' => [
@ -377,7 +381,7 @@ class AuthTest extends TestCase
$roles = Auth::getRoles($user);
$this->assertCount(11, $roles);
$this->assertCount(13, $roles);
$this->assertContains(Role::users()->toString(), $roles);
$this->assertContains(Role::user(ID::custom('123'))->toString(), $roles);
$this->assertContains(Role::users(Roles::DIMENSION_VERIFIED)->toString(), $roles);
@ -389,6 +393,8 @@ class AuthTest extends TestCase
$this->assertContains(Role::team(ID::custom('def'), 'guest')->toString(), $roles);
$this->assertContains(Role::member(ID::custom('456'))->toString(), $roles);
$this->assertContains(Role::member(ID::custom('abc'))->toString(), $roles);
$this->assertContains('label:vip', $roles);
$this->assertContains('label:admin', $roles);
// Disable all verification
$user['emailVerification'] = false;