From 56685790215e35c0ad2479ff79581526251cea0b Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 21 Apr 2021 16:54:05 +0200 Subject: [PATCH] fix: improve error message on anon login --- app/controllers/api/account.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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([