Skip to content

Commit

Permalink
Better token response check
Browse files Browse the repository at this point in the history
  • Loading branch information
ilijastuden committed Sep 25, 2015
1 parent d876cd9 commit 5c61c58
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/ActiveCollab/SDK/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
final class Client
{
const VERSION = '5.0.0'; // API wrapper version
const VERSION = '2.0.0'; // API wrapper version

/**
* Return user agent string
Expand All @@ -19,7 +19,7 @@ final class Client
*/
public static function getUserAgent()
{
return 'activeCollab API Wrapper; v' . self::VERSION;
return 'Active Collab API Wrapper; v' . self::VERSION;
}

// ---------------------------------------------------
Expand Down Expand Up @@ -182,10 +182,14 @@ public static function issueToken($email_or_username, $password, $client_name, $
if ($response instanceof Response && $response->isJson()) {
$json = $response->getJson();

if ($json['is_error']) {
$error = $json['error'];
} else {
if (is_array($json) && !empty($json['is_ok']) && !empty($json['token'])) {
return $json['token'];
} else {
if (empty($json['error'])) {
return 'Invalid response';
} else {
return $json['error'];
}
}
}

Expand Down

0 comments on commit 5c61c58

Please sign in to comment.