mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-27 15:59:29 +00:00
Fixed logout user method
This commit is contained in:
parent
6819628b3e
commit
4c9fd50e5e
@ -49,15 +49,11 @@ class userController
|
|||||||
* @url POST /user/disconnectUSER
|
* @url POST /user/disconnectUSER
|
||||||
*/
|
*/
|
||||||
public function disconnectUSER(){
|
public function disconnectUSER(){
|
||||||
//Check variables sent in request
|
|
||||||
if(!isset($_POST['token1']) OR !isset($_POST['token2']))
|
|
||||||
throw new RestException(401, "Missing data !");
|
|
||||||
|
|
||||||
//Prepare data
|
user_login_required();
|
||||||
$tokens = array($_POST['token1'], $_POST['token2']);
|
|
||||||
|
|
||||||
//Try to delete token
|
//Try to delete token
|
||||||
if(!CS::get()->user->deleteUserLoginToken($tokens, APIServiceID))
|
if(!CS::get()->user->deleteUserLoginToken(userID, APIServiceID))
|
||||||
throw new RestException(500, "Something went wrong while trying to logout user !");
|
throw new RestException(500, "Something went wrong while trying to logout user !");
|
||||||
|
|
||||||
//Everything is ok
|
//Everything is ok
|
||||||
|
@ -86,20 +86,16 @@ class User{
|
|||||||
/**
|
/**
|
||||||
* Delete token from given informations
|
* Delete token from given informations
|
||||||
*
|
*
|
||||||
* @param Array $tokens The tokens to delete
|
* @param Integer $userID The ID of the user to delete
|
||||||
* @param String $serviceID The service ID
|
* @param String $serviceID The service ID
|
||||||
* @return Boolean False if it fails
|
* @return Boolean False if it fails
|
||||||
*/
|
*/
|
||||||
public function deleteUserLoginToken(array $tokens, $serviceID){
|
public function deleteUserLoginToken($userID, $serviceID){
|
||||||
//Check the number of given tokens
|
|
||||||
if(count($tokens) != 2)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//Prepare database request
|
//Prepare database request
|
||||||
$condition = "token1 = ? AND token2 = ? AND ID_API_ServicesToken = ?";
|
$condition = "ID_utilisateurs = ? AND ID_API_ServicesToken = ?";
|
||||||
$values = array(
|
$values = array(
|
||||||
$tokens[0],
|
$userID,
|
||||||
$tokens[1],
|
|
||||||
$serviceID
|
$serviceID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user