diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index c7c8fe3ff..d8e0ac3bf 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -484,6 +484,10 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') 'registration' => \time(), 'reset' => false, 'name' => $name, + 'prefs' => [], + 'sessions' => [], + 'tokens' => [], + 'memberships' => [], ])); } catch (Duplicate $th) { throw new Exception('Account already exists', 409); @@ -638,7 +642,11 @@ App::post('/v1/account/sessions/anonymous') 'passwordUpdate' => \time(), 'registration' => \time(), 'reset' => false, - 'name' => null + 'name' => null, + 'prefs' => [], + 'sessions' => [], + 'tokens' => [], + 'memberships' => [], ])); } catch (Exception $th) { throw new Exception('Failed saving user to DB', 500); diff --git a/app/init.php b/app/init.php index 4a346a3ef..93ca871e9 100644 --- a/app/init.php +++ b/app/init.php @@ -485,8 +485,8 @@ App::setResource('user', function($mode, $project, $console, $request, $response $user = $dbForInternal->getDocument('users', $jwtUserId); } - if (empty($user->search('$id', $jwtSessionId, $user->getAttribute('tokens')))) { // Match JWT to active token - $user = new Document(['$id' => '', '$collection' => Database::SYSTEM_COLLECTION_USERS]); + if (empty($user->search('$id', $jwtSessionId, $user->getAttribute('sessions')))) { // Match JWT to active token + $user = new Document(['$id' => '', '$collection' => 'users']); } } diff --git a/composer.lock b/composer.lock index 9537c8356..ef8f6ed82 100644 --- a/composer.lock +++ b/composer.lock @@ -1923,7 +1923,7 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/database", - "reference": "11a149d2fd04b73c9fddffb93e96efc78d4a6039" + "reference": "20d189c6687ebfe82c3148794a01f51ebc6efb05" }, "require": { "ext-mongodb": "*", @@ -1970,7 +1970,7 @@ "upf", "utopia" ], - "time": "2021-05-06T20:03:31+00:00" + "time": "2021-05-08T22:11:07+00:00" }, { "name": "utopia-php/domains",