feat: implement logout method
This commit is contained in:
parent
de5aa03ba3
commit
5381184a07
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue