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 */
export async function logout() {
try {
await window.main.insomniaFetch({
method: 'POST',
path: '/auth/logout',
sessionId: getCurrentSessionId(),
});
} catch (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);
const sessionId = getCurrentSessionId();
if (sessionId) {
try {
window.main.insomniaFetch({
method: 'POST',
path: '/auth/logout',
sessionId,
});
} catch (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();