feat: implement logout method

This commit is contained in:
Derrick Hammer 2024-03-17 09:34:34 -04:00
parent de5aa03ba3
commit 5381184a07
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 13 additions and 5 deletions

View File

@ -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<boolean> {
this._jwtToken = undefined;
return true;
}
public async register(registerRequest: RegisterRequest): Promise<boolean> {
let ret: AxiosResponse<void>;
try {
@ -199,6 +195,18 @@ export class AccountApi {
return this.checkSuccessVal(ret);
}
public async logout(): Promise<boolean> {
try {
await postApiAuthLogout(this.buildOptions());
} catch (e) {
return false;
}
this._jwtToken = undefined;
return true;
}
private checkSuccessBool(ret: AxiosResponse<void>): boolean {
return ret.status === 200;
}