Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ public function requestToken( $tokenParams = [], $authOptions = [] ) {
$authHeaders = false
);

if ( empty( $res->token ) ) { // just in case.. an AblyRequestException should be thrown on the previous step with a 4XX error code on failure
// just in case.. an AblyRequestException should be thrown on the
// previous step with a 4XX error code on failure
if ( empty( $res->token ) ) {
throw new AblyException( 'Failed to get a token', 40100, 401 );
}

Expand Down
10 changes: 0 additions & 10 deletions src/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,6 @@ public function __publish_request_body($first) {
$json = '[' . implode( ',', $jsonArray ) . ']';
}

// if the message has a clientId set and we're using token based auth,
// the clientIds must match unless we're a wildcard client
$authClientId = $this->ably->auth->clientId;
if ( !empty( $msg->clientId ) && !$this->ably->auth->isUsingBasicAuth()
&& $authClientId != '*' && $msg->clientId != $authClientId) {
throw new AblyException(
'Message\'s clientId does not match the clientId of the authorisation token.', 40102, 401
);
}

return $json;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/ClientIdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function testClientIdLib() {
$msg->clientId = 'DIFFERENT_clientId';

$this->expectException(AblyException::class);
$this->expectExceptionCode(40102);
$this->expectExceptionCode(40012);
$channel->publish( $msg ); // mismatched clientIds, should throw an exception
}

Expand Down Expand Up @@ -263,7 +263,7 @@ public function testRSA8f2() {
$channel = $ablyClient->channels->get( 'persisted:RSA8f2' );

$this->expectException(AblyException::class);
$this->expectExceptionCode(40102);
$this->expectExceptionCode(40012);
$channel->publish( 'testEvent', 'testData', 'testClientId' );
}

Expand Down