From 3ab8a56ef7eb3ddecd6c1cdbc61691589843ed81 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 27 Mar 2020 15:13:16 +0100 Subject: [PATCH] Disconnect user from all services --- src/helpers/AccountHelper.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/helpers/AccountHelper.ts b/src/helpers/AccountHelper.ts index a527ced..a45f898 100644 --- a/src/helpers/AccountHelper.ts +++ b/src/helpers/AccountHelper.ts @@ -281,6 +281,20 @@ export class AccountHelper { }); } + /** + * Delete all user login tokens + * + * This method has for immediate effect to disconnect + * the user from all its devices + * + * @param userID Target user ID + */ + public static async DeleteAllUserLoginTokens(userID: number) { + await DatabaseHelper.DeleteRows(USERS_TOKENS_TABLE, { + user_id: userID + }) + } + /** * Get the ID of a user from a password reset token * @@ -483,6 +497,9 @@ export class AccountHelper { // Delete user background image await BackgroundImageHelper.Delete(userID); + + // Delete connections to all services + await this.DeleteAllUserLoginTokens(userID); */ // TODO : continue work