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; }