()
| 4 | import { clearClientTokenExpirations } from './tokens'; |
| 5 | |
| 6 | export async function logout() { |
| 7 | mainLogger.sub('logout').info('Logging out'); |
| 8 | |
| 9 | const logoutPromise = trpcClient.sessions.logout.mutate(); |
| 10 | |
| 11 | authStore().loggedIn = false; |
| 12 | |
| 13 | // Clear storage |
| 14 | |
| 15 | internals.sessionStorage.removeItem('demo'); |
| 16 | |
| 17 | internals.storage.removeItem('userId'); |
| 18 | internals.storage.removeItem('sessionId'); |
| 19 | internals.storage.removeItem('personalGroupId'); |
| 20 | |
| 21 | internals.storage.removeItem('publicKeyring'); |
| 22 | internals.storage.removeItem('encryptedPrivateKeyring'); |
| 23 | internals.storage.removeItem('encryptedSymmetricKeyring'); |
| 24 | |
| 25 | // Clear token expirations |
| 26 | |
| 27 | clearClientTokenExpirations(); |
| 28 | |
| 29 | // Clear loggedIn |
| 30 | |
| 31 | clearCookie('loggedIn'); |
| 32 | |
| 33 | await (globalThis as any).electronBridge?.clearLoggedInCookie(); |
| 34 | |
| 35 | internals.storage.removeItem('loggedIn'); |
| 36 | |
| 37 | try { |
| 38 | await logoutPromise; |
| 39 | } catch (error) { |
| 40 | mainLogger.error(error); |
| 41 | } |
| 42 | |
| 43 | location.href = multiModePath('/'); |
| 44 | } |
no test coverage detected