diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 902a6a1f65..1b89c98727 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -611,10 +611,14 @@ App::post('/v1/account/sessions/anonymous') $protocol = $request->getProtocol(); - if ($user->getId() || 'console' === $project->getId()) { + if ('console' === $project->getId()) { throw new Exception('Failed to create anonymous user.', 401); } + if ($user->getId()) { + throw new Exception('Cannot create an anonymous user when logged in.', 401); + } + Authorization::disable(); try { $user = $projectDB->createDocument([