From 82c47e7b11b107e22ccba71095ac17dcdc75a752 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 10 May 2018 08:53:18 +0200 Subject: [PATCH] Ready to implement account deletion. --- classes/components/AccountComponent.php | 38 +++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/classes/components/AccountComponent.php b/classes/components/AccountComponent.php index 5456a6f..7fac8da 100644 --- a/classes/components/AccountComponent.php +++ b/classes/components/AccountComponent.php @@ -102,7 +102,7 @@ class AccountComponent { } /** - * Delete token from given informations + * Delete login token from given information of a single service * * @param int $userID The ID of the user to delete * @param string $serviceID The service ID @@ -125,6 +125,30 @@ class AccountComponent { return true; } + /** + * Delete all the logins tokens of a user - disconnect him from + * all the services he is connected to + * + * @param int $userID Target user ID + * @return bool TRUE for a success / FALSE else + */ + public function deleteAllUserLoginTokens(int $userID) : bool { + + //Prepare database request + $condition = "ID_utilisateurs = ?"; + $values = array( + $userID + ); + + //Try to perform request + if(!CS::get()->db->deleteEntry($this->userLoginAPItable, $condition, $values)) + return false; //Something went wrong during the request + + //Everything is ok + return true; + + } + /** * Get User ID from token * @@ -287,19 +311,29 @@ class AccountComponent { //Remove users from all its conversations if(!components()->conversations->deleteAllUserConversations($userID)) - return FALSE;*/ + return FALSE; //Delete all the notifications related with the user if(!components()->notifications->deleteAllRelatedWithUser($userID)) return FALSE; //Delete all user friends, including friendship requests + if(!components()->friends->deleteAllUserFriends($userID)) + return FALSE; //Delete user account image + if(!components()->accountImage->delete($userID)) + return FALSE; //Delete connections to all the services + if(!$this->deleteAllUserLoginTokens($userID)) + return FALSE;*/ //Delete user from the database + //WILL BE IMPLEMENTED WHEN LEGACY VERSION WILL BE REMOVED + + //Success + return FALSE; } }