diff --git a/app/config/avatars/flags/np.png b/app/config/avatars/flags/np.png index 09b2a4c228..4c0c2d7e5f 100644 Binary files a/app/config/avatars/flags/np.png and b/app/config/avatars/flags/np.png differ diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index a325bdd664..61b0e27be7 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -714,10 +714,16 @@ App::post('/v1/account/sessions/anonymous') $detector->getDevice() )); - $user->setAttribute('sessions', $session, Document::SET_TYPE_APPEND); - Authorization::setRole('user:'.$user->getId()); + $session = $projectDB->createDocument($session->getArrayCopy()); + + if (false === $session) { + throw new Exception('Failed saving session to DB', 500); + } + + $user->setAttribute('sessions', $session, Document::SET_TYPE_APPEND); + $user = $projectDB->updateDocument($user->getArrayCopy()); if (false === $user) { diff --git a/tests/e2e/Services/Account/AccountCustomClientTest.php b/tests/e2e/Services/Account/AccountCustomClientTest.php index 6c4de08fde..77a4f93686 100644 --- a/tests/e2e/Services/Account/AccountCustomClientTest.php +++ b/tests/e2e/Services/Account/AccountCustomClientTest.php @@ -240,6 +240,10 @@ class AccountCustomClientTest extends Scope ]); $this->assertEquals(201, $response['headers']['status-code']); + $this->assertIsArray($response['body']); + $this->assertNotEmpty($response['body']); + $this->assertNotEmpty($response['body']['$id']); + $this->assertNotEmpty($response['body']['userId']); $session = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_'.$this->getProject()['$id']];