1
0
Fork 0
mirror of synced 2024-05-29 17:09:48 +12:00

validate project deletion

This commit is contained in:
Eldad Fux 2020-01-31 01:50:17 +02:00
parent bf7839a6c8
commit b8b9435df5

View file

@ -2,6 +2,7 @@
global $utopia, $request, $response, $register, $user, $consoleDB, $projectDB, $providers;
use Auth\Auth;
use Utopia\Exception;
use Utopia\Response;
use Utopia\Validator\ArrayList;
@ -366,8 +367,13 @@ $utopia->delete('/v1/projects/:projectId')
->label('sdk.namespace', 'projects')
->label('sdk.method', 'delete')
->param('projectId', '', function () { return new UID(); }, 'Project unique ID.')
->param('password', '', function () { return new UID(); }, 'Your Password for confirmation.')
->action(
function ($projectId) use ($response, $consoleDB) {
function ($projectId, $password) use ($response, $consoleDB, $user) {
if (!Auth::passwordVerify($password, $user->getAttribute('password'))) { // Double check user password
throw new Exception('Invalid credentials', 401);
}
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {