do not try to post to /logout if not logged in and make it fire and forget (#6619)

This commit is contained in:
James Gatz 2023-10-02 13:45:08 +02:00 committed by GitHub
parent 25cd5e335b
commit 8b85265ca4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -200,16 +200,19 @@ export function isLoggedIn() {
/** Log out and delete session data */ /** Log out and delete session data */
export async function logout() { export async function logout() {
try { const sessionId = getCurrentSessionId();
await window.main.insomniaFetch({ if (sessionId) {
method: 'POST', try {
path: '/auth/logout', window.main.insomniaFetch({
sessionId: getCurrentSessionId(), method: 'POST',
}); path: '/auth/logout',
} catch (error) { sessionId,
// Not a huge deal if this fails, but we don't want it to prevent the });
// user from signing out. } catch (error) {
console.warn('Failed to logout', error); // Not a huge deal if this fails, but we don't want it to prevent the
// user from signing out.
console.warn('Failed to logout', error);
}
} }
_unsetSessionData(); _unsetSessionData();