From 5381184a07b8f74241c57b97e7ac011d2251466b Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 17 Mar 2024 09:34:34 -0400 Subject: [PATCH] feat: implement logout method --- src/account.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/account.ts b/src/account.ts index 45db522..0c84035 100644 --- a/src/account.ts +++ b/src/account.ts @@ -25,6 +25,7 @@ import { postApiAuthOtpDisable, PasswordResetRequest, postApiAuthPasswordResetConfirm, + postApiAuthLogout, } from "./account/generated/index.js"; import { AxiosResponse } from "axios"; @@ -67,11 +68,6 @@ export class AccountApi { return false; } - public async logout(): Promise { - this._jwtToken = undefined; - return true; - } - public async register(registerRequest: RegisterRequest): Promise { let ret: AxiosResponse; try { @@ -199,6 +195,18 @@ export class AccountApi { return this.checkSuccessVal(ret); } + public async logout(): Promise { + try { + await postApiAuthLogout(this.buildOptions()); + } catch (e) { + return false; + } + + this._jwtToken = undefined; + + return true; + } + private checkSuccessBool(ret: AxiosResponse): boolean { return ret.status === 200; }