mirror of
https://github.com/appwrite/appwrite
synced 2026-05-22 08:28:42 +00:00
feat(Auth): improve getRoles method
This commit is contained in:
parent
b617afb17c
commit
0b344e182c
1 changed files with 8 additions and 5 deletions
|
|
@ -3,6 +3,7 @@
|
|||
namespace Appwrite\Auth;
|
||||
|
||||
use Appwrite\Database\Document;
|
||||
use Appwrite\Database\Validator\Authorization;
|
||||
|
||||
class Auth
|
||||
{
|
||||
|
|
@ -282,11 +283,13 @@ class Auth
|
|||
*/
|
||||
public static function getRoles(Document $user): array
|
||||
{
|
||||
if ($user->getId()) {
|
||||
$roles[] = 'user:'.$user->getId();
|
||||
$roles[] = 'role:'.Auth::USER_ROLE_MEMBER;
|
||||
} else {
|
||||
return ['role:'.Auth::USER_ROLE_GUEST];
|
||||
if (self::isPrivilegedUser(Authorization::$roles) || self::isAppUser(Authorization::$roles)) {
|
||||
if ($user->getId()) {
|
||||
$roles[] = 'user:'.$user->getId();
|
||||
$roles[] = 'role:'.Auth::USER_ROLE_MEMBER;
|
||||
} else {
|
||||
return ['role:'.Auth::USER_ROLE_GUEST];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($user->getAttribute('memberships', []) as $node) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue