1
0
Fork 0
mirror of synced 2024-09-30 17:26:48 +13:00

Exception fixes

This commit is contained in:
Jake Barnby 2022-08-16 21:07:30 +12:00
parent 5d84d6d43f
commit 326220762e
3 changed files with 4 additions and 4 deletions

View file

@ -1520,7 +1520,7 @@ App::patch('/v1/account/password')
->action(function (string $password, string $oldPassword, Response $response, Document $user, Database $dbForProject, Audit $audits, Stats $usage, Event $events) {
// Check old password only if its an existing user.
if ($user->getAttribute('passwordUpdate') !== 0 && !Auth::passwordVerify($oldPassword, $user->getAttribute('password'))) { // Double check user password
if ($user->getAttribute('passwordUpdate') !== null && !Auth::passwordVerify($oldPassword, $user->getAttribute('password'))) { // Double check user password
throw new Exception(Exception::USER_INVALID_CREDENTIALS);
}

View file

@ -2185,7 +2185,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen
$document = $dbForProject->getDocument('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $documentId);
if ($document->isEmpty()) {
throw new Exception('No document found', 404, Exception::DOCUMENT_NOT_FOUND);
throw new Exception(Exception::DOCUMENT_NOT_FOUND);
}
if ($documentSecurity) {
@ -2332,7 +2332,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
$data = (\is_string($data)) ? \json_decode($data, true) : $data; // Cast to JSON array
if (empty($data) && \is_null($permissions)) {
throw new Exception('Missing payload or permissions', 400, Exception::DOCUMENT_MISSING_PAYLOAD);
throw new Exception(Exception::DOCUMENT_MISSING_PAYLOAD);
}
$database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId));

View file

@ -1336,7 +1336,7 @@ App::put('/v1/storage/buckets/:bucketId/files/:fileId')
}
$role = \str_replace([$type, '(', ')', '"', ' '], '', $permission);
if (!Authorization::isRole($role)) {
throw new Exception('Permissions must be one of: (' . \implode(', ', Authorization::getRoles()) . ')', 400, Exception::USER_UNAUTHORIZED);
throw new Exception(Exception::USER_UNAUTHORIZED, 'Permissions must be one of: (' . \implode(', ', Authorization::getRoles()) . ')');
}
}
}