feat: implement logout method
This commit is contained in:
parent
de5aa03ba3
commit
5381184a07
|
@ -25,6 +25,7 @@ import {
|
||||||
postApiAuthOtpDisable,
|
postApiAuthOtpDisable,
|
||||||
PasswordResetRequest,
|
PasswordResetRequest,
|
||||||
postApiAuthPasswordResetConfirm,
|
postApiAuthPasswordResetConfirm,
|
||||||
|
postApiAuthLogout,
|
||||||
} from "./account/generated/index.js";
|
} from "./account/generated/index.js";
|
||||||
import { AxiosResponse } from "axios";
|
import { AxiosResponse } from "axios";
|
||||||
|
|
||||||
|
@ -67,11 +68,6 @@ export class AccountApi {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async logout(): Promise<boolean> {
|
|
||||||
this._jwtToken = undefined;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async register(registerRequest: RegisterRequest): Promise<boolean> {
|
public async register(registerRequest: RegisterRequest): Promise<boolean> {
|
||||||
let ret: AxiosResponse<void>;
|
let ret: AxiosResponse<void>;
|
||||||
try {
|
try {
|
||||||
|
@ -199,6 +195,18 @@ export class AccountApi {
|
||||||
return this.checkSuccessVal(ret);
|
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 {
|
private checkSuccessBool(ret: AxiosResponse<void>): boolean {
|
||||||
return ret.status === 200;
|
return ret.status === 200;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue