1
0
Fork 0
mirror of synced 2024-06-18 18:54:55 +12:00

fix(account): add anon sessiom id

This commit is contained in:
Torsten Dittmann 2021-05-20 15:41:55 +02:00
parent bcdf8835ca
commit d118b09d90
2 changed files with 12 additions and 2 deletions

View file

@ -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) {

View file

@ -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']];