mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Update AuthenticationHandler to make session parameter optional and add validation for empty session tokens. Update error message in PresenceRealtimeClientTest for clarity.
This commit is contained in:
@@ -24,7 +24,7 @@ class AuthenticationHandler extends Action
|
||||
$this
|
||||
->desc('Authenticate the connection with a session token')
|
||||
->label(Dispatcher::LABEL_MESSAGE_TYPE, 'authentication')
|
||||
->param('session', '', new Text(2048), 'Encoded session token')
|
||||
->param('session', '', new Text(2048), 'Encoded session token', optional: true)
|
||||
->inject('connection')
|
||||
->inject('realtime')
|
||||
->inject('database')
|
||||
@@ -44,6 +44,10 @@ class AuthenticationHandler extends Action
|
||||
Registry $register,
|
||||
Response $response,
|
||||
): array {
|
||||
if ($session === '') {
|
||||
throw new Exception(Exception::REALTIME_MESSAGE_FORMAT_INVALID, 'Payload is not valid.');
|
||||
}
|
||||
|
||||
$store = new Store();
|
||||
$store->decode($session);
|
||||
|
||||
|
||||
@@ -382,7 +382,7 @@ class PresenceRealtimeClientTest extends Scope
|
||||
],
|
||||
]));
|
||||
$missingStatus = $this->receiveErrorMessage($client);
|
||||
$this->assertStringContainsString('status must be provided', $missingStatus['data']['message'] ?? '');
|
||||
$this->assertStringContainsString('status is required', $missingStatus['data']['message'] ?? '');
|
||||
$this->assertQuietFor(
|
||||
$client,
|
||||
fn (array $frame): bool => ($frame['type'] ?? null) === 'event'
|
||||
|
||||
Reference in New Issue
Block a user