feat: logout prev user before accepting new invite
This commit is contained in:
@@ -5,7 +5,7 @@ import { currentOrg, orgs, defaultCurrentOrgState } from '$lib/utils/store/org';
|
|||||||
import { user, profile, defaultProfileState, defaultUserState } from '$lib/utils/store/user';
|
import { user, profile, defaultProfileState, defaultUserState } from '$lib/utils/store/user';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
|
|
||||||
export async function logout() {
|
export async function logout(redirect = true) {
|
||||||
const { error } = await supabase.auth.signOut();
|
const { error } = await supabase.auth.signOut();
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
@@ -19,5 +19,8 @@ export async function logout() {
|
|||||||
|
|
||||||
capturePosthogEvent('user_logged_out');
|
capturePosthogEvent('user_logged_out');
|
||||||
posthog.reset();
|
posthog.reset();
|
||||||
goto('/login');
|
|
||||||
|
if (redirect) {
|
||||||
|
goto('/login');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,10 @@
|
|||||||
import AuthUI from '$lib/components/AuthUI/index.svelte';
|
import AuthUI from '$lib/components/AuthUI/index.svelte';
|
||||||
import { currentOrg, currentOrgPath } from '$lib/utils/store/org';
|
import { currentOrg, currentOrgPath } from '$lib/utils/store/org';
|
||||||
import { setTheme } from '$lib/utils/functions/theme';
|
import { setTheme } from '$lib/utils/functions/theme';
|
||||||
import type { CurrentOrg } from '$lib/utils/types/org.js';
|
import type { CurrentOrg } from '$lib/utils/types/org';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import type { Profile } from '$lib/components/Course/components/People/types';
|
import type { Profile } from '$lib/components/Course/components/People/types';
|
||||||
|
import { logout } from '$lib/utils/functions/logout';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
@@ -128,6 +129,8 @@
|
|||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
setTheme(data.currentOrg?.theme || '');
|
setTheme(data.currentOrg?.theme || '');
|
||||||
|
|
||||||
|
logout(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
$: errors.confirmPassword = getConfirmPasswordError(fields);
|
$: errors.confirmPassword = getConfirmPasswordError(fields);
|
||||||
|
|||||||
Reference in New Issue
Block a user