fix: org data persists after logout (#52)

* fix logout bug

* Update index.svelte

---------

Co-authored-by: macbook <[email protected]>
Co-authored-by: Rotimi Best <[email protected]>
This commit is contained in:
Vanessa Osuka
2023-12-01 08:49:47 +03:00
committed by GitHub
co-authored by macbook Rotimi Best
parent 0081a6a910
commit c1d1b820d2
@@ -5,11 +5,26 @@
import { VARIANTS } from '$lib/components/PrimaryButton/constants';
import { supabase } from '$lib/utils/functions/supabase';
import { capturePosthogEvent } from '$lib/utils/services/posthog';
import { currentOrg, orgs } from '$lib/utils/store/org';
async function logout() {
const { error } = await supabase.auth.signOut();
console.error('Error logging out: ', error);
// Reset organization values, TODO: consider abstracting if needed in other places
currentOrg.set({
id: '',
name: '',
shortName: '',
siteName: '',
avatar_url: '',
memberId: '',
role_id: '',
landingpage: {},
theme: ''
})
orgs.set([]);
capturePosthogEvent('user_logged_out');
posthog.reset();
goto('/login');