Merge pull request #1103 from TorstenDittmann/fix-anon-login-error

fix: improve error message on anon login
This commit is contained in:
Eldad A. Fux 2021-04-22 10:08:09 +03:00 committed by GitHub
commit 9dd754959d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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([