From 900c7c7e5e27623fc49efdab056f41e21b0f0a10 Mon Sep 17 00:00:00 2001 From: Pierre Date: Tue, 31 Oct 2017 14:25:33 +0100 Subject: [PATCH] Fixed error in login process of the API --- RestControllers/userController.php | 2 +- classes/components/user.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RestControllers/userController.php b/RestControllers/userController.php index e8e881d..6468084 100644 --- a/RestControllers/userController.php +++ b/RestControllers/userController.php @@ -30,7 +30,7 @@ class userController //Try to perform login $loginTokens = CS::get()->components->user->generateUserLoginTokens($userMail, $userPassword, APIServiceID, $db); - if(!$loginTokens) + if(count($loginTokens) == 0) throw new RestException(401, "Invalid e-mail address / password !"); //Return result with tokens diff --git a/classes/components/user.php b/classes/components/user.php index 9694876..6fc56dc 100644 --- a/classes/components/user.php +++ b/classes/components/user.php @@ -43,7 +43,7 @@ class User{ //Check if there is anything if(count($userInfos) == 0) - return false; //Not any account was found + return array(); //Not any account was found //Extract first value ID $userID = $userInfos[0]['ID']; @@ -69,7 +69,7 @@ class User{ "token2" => $token2 ); if(!CS::get()->db->addLine($tableName, $insertValues)) - return false; //Something went wrong + return array(); //Something went wrong //We can return tokens return array($token1, $token2);