fix: auth flow bug on joining course

This commit is contained in:
Rotimi Best
2023-12-05 08:31:26 +03:00
parent 8fc3a5e1fc
commit 6fa1d0fcfb
12 changed files with 69 additions and 86 deletions
@@ -5,25 +5,17 @@
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';
import { currentOrg, orgs, defaultCurrentOrgState } from '$lib/utils/store/org';
import { user, profile, defaultProfileState, defaultUserState } from '$lib/utils/store/user';
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([]);
currentOrg.set(defaultCurrentOrgState);
orgs.set([]);
user.set(defaultUserState);
profile.set(defaultProfileState);
capturePosthogEvent('user_logged_out');
posthog.reset();