fix(org-site): redirect students away from the admin dashboard to the LMS
A student opening /org/[slug] on self-hosted stayed on the admin dashboard. The existing routeUserToNextPage redirect is gated by shouldRedirectOnAuth (login/signup/onboarding only) and runs once at app init, so it never caught this route. Add a reactive guard in the admin org layout that sends students to /lms, gated on appInitApi.isInitializedAndReady so the role is actually known before deciding (the student flag defaults to false while loading).
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
|
import { resolve } from '$app/paths';
|
||||||
import * as Sidebar from '@cio/ui/base/sidebar';
|
import * as Sidebar from '@cio/ui/base/sidebar';
|
||||||
import { Skeleton } from '@cio/ui/base/skeleton';
|
import { Skeleton } from '@cio/ui/base/skeleton';
|
||||||
import { currentOrg } from '$lib/utils/store/org';
|
import { currentOrg } from '$lib/utils/store/org';
|
||||||
|
import { isStudentExperience } from '$lib/utils/store/app';
|
||||||
|
import { appInitApi } from '$features/app/init.svelte';
|
||||||
import { AppHeader } from '$features/ui';
|
import { AppHeader } from '$features/ui';
|
||||||
import { PUBLIC_IS_SELFHOSTED } from '$env/static/public';
|
import { PUBLIC_IS_SELFHOSTED } from '$env/static/public';
|
||||||
|
|
||||||
@@ -24,6 +27,14 @@
|
|||||||
$effect(() => {
|
$effect(() => {
|
||||||
data.orgName === '*' && redirect($currentOrg.siteName);
|
data.orgName === '*' && redirect($currentOrg.siteName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
// Decide only once the account/role has loaded — until then the student flag
|
||||||
|
// defaults to false and a student is indistinguishable from an admin.
|
||||||
|
if (appInitApi.isInitializedAndReady && $isStudentExperience) {
|
||||||
|
goto(resolve('/lms', {}));
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if PUBLIC_IS_SELFHOSTED !== 'true'}
|
{#if PUBLIC_IS_SELFHOSTED !== 'true'}
|
||||||
|
|||||||
Reference in New Issue
Block a user