1
0
Fork 0
mirror of synced 2024-06-03 19:34:54 +12:00

Set user roles at app init

This commit is contained in:
Eldad Fux 2020-06-22 19:31:59 +03:00
parent 416d767ff0
commit e6a4020fd1
2 changed files with 5 additions and 27 deletions

View file

@ -180,6 +180,8 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $
}
}, $user->getAttribute('memberships', []));
$user->setAttribute('roles', Authorization::getRoles());
// TDOO Check if user is god
if (!\in_array($scope, $scopes)) {

View file

@ -709,15 +709,7 @@ $utopia->patch('/v1/account/name')
->setParam('resource', 'users/'.$user->getId())
;
$response->json(\array_merge($user->getArrayCopy(\array_merge(
[
'$id',
'email',
'registration',
'name',
],
$oauth2Keys
)), ['roles' => Authorization::getRoles()]));
$response->dynamic($user);
}
);
@ -751,15 +743,7 @@ $utopia->patch('/v1/account/password')
->setParam('resource', 'users/'.$user->getId())
;
$response->json(\array_merge($user->getArrayCopy(\array_merge(
[
'$id',
'email',
'registration',
'name',
],
$oauth2Keys
)), ['roles' => Authorization::getRoles()]));
$response->dynamic($user);
}
);
@ -809,15 +793,7 @@ $utopia->patch('/v1/account/email')
->setParam('resource', 'users/'.$user->getId())
;
$response->json(\array_merge($user->getArrayCopy(\array_merge(
[
'$id',
'email',
'registration',
'name',
],
$oauth2Keys
)), ['roles' => Authorization::getRoles()]));
$response->dynamic($user);
}
);