From f888b96c7a9f730f461e57b3305e3ca39d027de6 Mon Sep 17 00:00:00 2001 From: MillenniumEarl Date: Wed, 10 Mar 2021 12:25:43 +0100 Subject: [PATCH] Add logout method --- src/index.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/index.ts b/src/index.ts index b3ba4c3..6531359 100644 --- a/src/index.ts +++ b/src/index.ts @@ -127,6 +127,19 @@ export async function login( return result; } +/** + * Close the currently open session. + * + * You **must** be logged in to the portal before calling this method. + */ +export async function logout(): Promise { + // Check if the user is logged + if (!shared.isLogged) throw new UserNotLogged(USER_NOT_LOGGED); + + await shared.session.delete(); + shared.setIsLogged(false); +} + /** * Chek if exists a new version of the handiwork. *