fix: delete all sessions event
This commit is contained in:
parent
0b025cf57a
commit
5a9a967f35
3 changed files with 33 additions and 38 deletions
|
@ -1755,9 +1755,7 @@ App::delete('/v1/account/sessions')
|
|||
$audits->setResource('user/' . $user->getId());
|
||||
|
||||
if (!Config::getParam('domainVerification')) {
|
||||
$response
|
||||
->addHeader('X-Fallback-Cookies', \json_encode([]))
|
||||
;
|
||||
$response->addHeader('X-Fallback-Cookies', \json_encode([]));
|
||||
}
|
||||
|
||||
$session
|
||||
|
@ -1765,12 +1763,16 @@ App::delete('/v1/account/sessions')
|
|||
->setAttribute('countryName', $locale->getText('countries.'.strtolower($session->getAttribute('countryCode')), $locale->getText('locale.country.unknown')))
|
||||
;
|
||||
|
||||
if ($session->getAttribute('secret') == Auth::hash(Auth::$secret)) { // If current session delete the cookies too
|
||||
if ($session->getAttribute('secret') == Auth::hash(Auth::$secret)) {
|
||||
$session->setAttribute('current', true);
|
||||
|
||||
// If current session delete the cookies too
|
||||
$response
|
||||
->addCookie(Auth::$cookieName . '_legacy', '', \time() - 3600, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, null)
|
||||
->addCookie(Auth::$cookieName, '', \time() - 3600, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, Config::getParam('cookieSamesite'))
|
||||
;
|
||||
->addCookie(Auth::$cookieName, '', \time() - 3600, '/', Config::getParam('cookieDomain'), ('https' == $protocol), true, Config::getParam('cookieSamesite'));
|
||||
|
||||
// Use current session for events.
|
||||
$events->setPayload($response->output($session, Response::MODEL_SESSION));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1780,12 +1782,7 @@ App::delete('/v1/account/sessions')
|
|||
|
||||
$events
|
||||
->setParam('userId', $user->getId())
|
||||
->setParam('sessionId', $session->getId())
|
||||
->setPayload($response->output(new Document([
|
||||
'sessions' => $sessions,
|
||||
'total' => $numOfSessions,
|
||||
]), Response::MODEL_SESSION_LIST))
|
||||
;
|
||||
->setParam('sessionId', $session->getId());
|
||||
|
||||
$usage
|
||||
->setParam('users.sessions.delete', $numOfSessions)
|
||||
|
|
|
@ -693,7 +693,6 @@ App::get('/v1/functions/:functionId/deployments')
|
|||
$cursorDeployment = $dbForProject->getDocument('deployments', $cursor);
|
||||
|
||||
if ($cursorDeployment->isEmpty()) {
|
||||
// TODO: Shouldn't this be a 404 error ?
|
||||
throw new Exception("Tag '{$cursor}' for the 'cursor' value not found.", 400, Exception::GENERAL_CURSOR_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -347,31 +347,30 @@ class WebhooksCustomClientTest extends Scope
|
|||
$this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']);
|
||||
$this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']);
|
||||
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
|
||||
$this->assertEquals($webhook['data']['total'], 2);
|
||||
$this->assertNotEmpty($webhook['data']['sessions'][1]['$id']);
|
||||
$this->assertNotEmpty($webhook['data']['sessions'][1]['userId']);
|
||||
$this->assertIsInt($webhook['data']['sessions'][1]['expire']);
|
||||
$this->assertEquals($webhook['data']['sessions'][1]['ip'], '127.0.0.1');
|
||||
$this->assertNotEmpty($webhook['data']['sessions'][1]['osCode']);
|
||||
$this->assertIsString($webhook['data']['sessions'][1]['osCode']);
|
||||
$this->assertNotEmpty($webhook['data']['sessions'][1]['osName']);
|
||||
$this->assertIsString($webhook['data']['sessions'][1]['osName']);
|
||||
$this->assertNotEmpty($webhook['data']['sessions'][1]['osVersion']);
|
||||
$this->assertIsString($webhook['data']['sessions'][1]['osVersion']);
|
||||
$this->assertEquals($webhook['data']['sessions'][1]['clientType'], 'browser');
|
||||
$this->assertEquals($webhook['data']['sessions'][1]['clientCode'], 'CH');
|
||||
$this->assertEquals($webhook['data']['sessions'][1]['clientName'], 'Chrome');
|
||||
$this->assertNotEmpty($webhook['data']['sessions'][1]['clientVersion']);
|
||||
$this->assertIsString($webhook['data']['sessions'][1]['clientVersion']);
|
||||
$this->assertNotEmpty($webhook['data']['sessions'][1]['clientEngine']);
|
||||
$this->assertIsString($webhook['data']['sessions'][1]['clientEngine']);
|
||||
$this->assertIsString($webhook['data']['sessions'][1]['clientEngineVersion']);
|
||||
$this->assertIsString($webhook['data']['sessions'][1]['deviceName']);
|
||||
$this->assertIsString($webhook['data']['sessions'][1]['deviceBrand']);
|
||||
$this->assertIsString($webhook['data']['sessions'][1]['deviceModel']);
|
||||
$this->assertIsString($webhook['data']['sessions'][1]['countryCode']);
|
||||
$this->assertIsString($webhook['data']['sessions'][1]['countryName']);
|
||||
$this->assertEquals($webhook['data']['sessions'][1]['current'], true);
|
||||
$this->assertNotEmpty($webhook['data']['$id']);
|
||||
$this->assertNotEmpty($webhook['data']['userId']);
|
||||
$this->assertIsInt($webhook['data']['expire']);
|
||||
$this->assertEquals($webhook['data']['ip'], '127.0.0.1');
|
||||
$this->assertNotEmpty($webhook['data']['osCode']);
|
||||
$this->assertIsString($webhook['data']['osCode']);
|
||||
$this->assertNotEmpty($webhook['data']['osName']);
|
||||
$this->assertIsString($webhook['data']['osName']);
|
||||
$this->assertNotEmpty($webhook['data']['osVersion']);
|
||||
$this->assertIsString($webhook['data']['osVersion']);
|
||||
$this->assertEquals($webhook['data']['clientType'], 'browser');
|
||||
$this->assertEquals($webhook['data']['clientCode'], 'CH');
|
||||
$this->assertEquals($webhook['data']['clientName'], 'Chrome');
|
||||
$this->assertNotEmpty($webhook['data']['clientVersion']);
|
||||
$this->assertIsString($webhook['data']['clientVersion']);
|
||||
$this->assertNotEmpty($webhook['data']['clientEngine']);
|
||||
$this->assertIsString($webhook['data']['clientEngine']);
|
||||
$this->assertIsString($webhook['data']['clientEngineVersion']);
|
||||
$this->assertIsString($webhook['data']['deviceName']);
|
||||
$this->assertIsString($webhook['data']['deviceBrand']);
|
||||
$this->assertIsString($webhook['data']['deviceModel']);
|
||||
$this->assertIsString($webhook['data']['countryCode']);
|
||||
$this->assertIsString($webhook['data']['countryName']);
|
||||
$this->assertEquals($webhook['data']['current'], true);
|
||||
|
||||
$accountSession = $this->client->call(Client::METHOD_POST, '/account/sessions', array_merge([
|
||||
'origin' => 'http://localhost',
|
||||
|
|
Loading…
Reference in a new issue