[fix] bad token were not properly recognized

This commit is contained in:
Benjamin Sonntag 2015-01-05 00:58:25 +01:00
parent 7609fe6d39
commit 66e97ff156
2 changed files with 5 additions and 6 deletions

View File

@ -13,7 +13,7 @@ class Alternc_Api_Auth_Sharedsecret implements Alternc_Api_Auth_Interface {
const ERR_INVALID_SECRET = 1111802; const ERR_INVALID_SECRET = 1111802;
const ERR_INVALID_LOGIN = 1111803; const ERR_INVALID_LOGIN = 1111803;
const ERR_DISABLED_ACCOUNT = 1111804; const ERR_DISABLED_ACCOUNT = 1111804;
const ERR_INVALID_AUTH = 1111805;
/** /**
* Constructor of the Shared Secret Api Auth * Constructor of the Shared Secret Api Auth

View File

@ -116,11 +116,10 @@ class Alternc_Api_Token {
} }
$stmt=$db->prepare("SELECT * FROM token WHERE token=?"); $stmt=$db->prepare("SELECT * FROM token WHERE token=?");
$stmt->execute(array($token)); $stmt->execute(array($token));
while ($tok=$stmt->fetch(PDO::FETCH_OBJ)) { if ( $tok=$stmt->fetch(PDO::FETCH_OBJ) ) {
return new Alternc_Api_Token( json_decode($tok->data,true) ); return new Alternc_Api_Token( json_decode($tok->data,true) );
} }
return new Alternc_Api_Response( array("code" => self::ERR_INVALID_TOKEN, "message" => "Invalid token") );
return null;
} }