Fixed membership creation from server
This commit is contained in:
parent
5c794dd22b
commit
7010cc361d
|
@ -50,7 +50,7 @@ $clients = \array_unique(\array_merge($clientsConsole, \array_map(function ($nod
|
|||
return false;
|
||||
}))));
|
||||
|
||||
$utopia->init(function () use ($utopia, $request, $response, &$user, $project, $console, $webhook, $mail, $audit, $usage, $clients, &$mode) {
|
||||
$utopia->init(function () use ($utopia, $request, $response, &$user, $project, $console, $webhook, $mail, $audit, $usage, $clients) {
|
||||
|
||||
$route = $utopia->match($request);
|
||||
|
||||
|
@ -160,7 +160,7 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $
|
|||
|
||||
$role = Auth::USER_ROLE_APP;
|
||||
$scopes = \array_merge($roles[$role]['scopes'], $key->getAttribute('scopes', []));
|
||||
$mode = APP_MODE_SERVER;
|
||||
|
||||
Authorization::setDefaultStatus(false); // Cancel security segmentation for API keys.
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ $utopia->post('/v1/teams')
|
|||
throw new Exception('Failed saving team to DB', 500);
|
||||
}
|
||||
|
||||
if ($mode !== APP_MODE_ADMIN && $user->getId()) { // Don't add user on server mode
|
||||
if ($mode !== APP_MODE_ADMIN && $user->getId()) { // Don't add user on app/server mode
|
||||
$membership = new Document([
|
||||
'$collection' => Database::SYSTEM_COLLECTION_MEMBERSHIPS,
|
||||
'$permissions' => [
|
||||
|
@ -288,7 +288,7 @@ $utopia->post('/v1/teams/:teamId/memberships')
|
|||
}
|
||||
}
|
||||
|
||||
if (!$isOwner && (APP_MODE_ADMIN !== $mode) && (APP_MODE_SERVER !== $mode)) {
|
||||
if (!$isOwner && (APP_MODE_ADMIN !== $mode) && $user->getId()) { // Not owner, not admin, not app (server)
|
||||
throw new Exception('User is not allowed to send invitations for this team', 401);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ const APP_EMAIL_TEAM = 'team@localhost.test'; // Default email address
|
|||
const APP_EMAIL_SECURITY = 'security@localhost.test'; // Default security email address
|
||||
const APP_USERAGENT = APP_NAME.'-Server v%s. Please report abuse at %s';
|
||||
const APP_MODE_ADMIN = 'admin';
|
||||
const APP_MODE_SERVER = 'server';
|
||||
const APP_PAGING_LIMIT = 15;
|
||||
const APP_CACHE_BUSTER = 125;
|
||||
const APP_VERSION_STABLE = '0.6.2';
|
||||
|
|
Loading…
Reference in a new issue