fix: Await logout

This commit is contained in:
Tom Moor
2023-06-27 22:20:41 -04:00
parent 87a675d02b
commit f3d8129a13
3 changed files with 11 additions and 4 deletions

View File

@@ -12,6 +12,7 @@ import User from "~/models/User";
import env from "~/env";
import { client } from "~/utils/ApiClient";
import Desktop from "~/utils/Desktop";
import Logger from "~/utils/Logger";
const AUTH_STORE = "AUTH_STORE";
const NO_REDIRECT_PATHS = ["/", "/create", "/home", "/logout"];
@@ -322,7 +323,7 @@ export default class AuthStore {
}
// invalidate authentication token on server
client.post(`/auth.delete`);
const promise = client.post(`/auth.delete`);
// remove authentication token itself
removeCookie("accessToken", {
@@ -349,5 +350,11 @@ export default class AuthStore {
// Tell the host application we logged out, if any allows window cleanup.
Desktop.bridge?.onLogout?.();
this.rootStore.logout();
try {
await promise;
} catch (err) {
Logger.error("Failed to delete authentication", err);
}
};
}