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