Update Appwrite to add User labels to Auth roles
This commit is contained in:
parent
078dab38c5
commit
09f3577256
2 changed files with 11 additions and 1 deletions
|
@ -456,6 +456,10 @@ class Auth
|
|||
}
|
||||
}
|
||||
|
||||
foreach ($user->getAttribute('labels', []) as $label) {
|
||||
$roles[] = 'label:' . $label;
|
||||
}
|
||||
|
||||
return $roles;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue