fix: user as student in one org forced to lms, hidden bottom in docs

This commit is contained in:
Rotimi Best
2026-06-22 06:52:35 +01:00
parent f6bd0a5b1a
commit adfedfee4c
3 changed files with 34 additions and 2 deletions
@@ -21,6 +21,7 @@ import { setSentryUser } from '$lib/utils/services/sentry';
import { setTheme } from '$lib/utils/functions/theme';
import { setupAnalyticsBasedOnLicense } from '$lib/utils/functions/appSetup';
import shouldRedirectOnAuth from '$lib/utils/functions/routes/shouldRedirectOnAuth';
import { ROLE } from '@cio/utils/constants';
type AppSetupParams = {
isOrgSite: boolean;
@@ -206,7 +207,27 @@ class AppInitApi extends BaseApi {
return shouldGoToLMS ? this.goToLMS() : this.goToOrg();
}
goToLMS() {
goToLMS(isOrgSite: boolean) {
const isCloud = PUBLIC_IS_SELFHOSTED !== 'true';
const isStudent = get(isOrgStudent);
const selectedOrg = get(currentOrg);
const userHasOneOrg = this.data.organizations === 1;
const userIsStudentInAllOrgs = this.data.organizations.every((org) => org.roleId === ROLE.STUDENT);
const userIsAdminInAtleastOneOrg = this.data.organizations.some((org) => org.roleId === ROLE.ADMIN);
if (userHasOneOrg && isCloud && !isOrgSite && isStudent && selectedOrg.siteName && userIsStudentInAllOrgs) {
window.location.href = getOrgPublicUrl(selectedOrg, '/lms');
return;
}
// User is an admin in at least one org, so they should be redirected to the org dashboard.
if (userIsAdminInAtleastOneOrg && isCloud && !isOrgSite) {
const orgWithAdminRole = this.data.organizations.find((org) => org.roleId === ROLE.ADMIN);
goto(resolve(`/org/${orgWithAdminRole.siteName}`, {}));
return;
}
goto(resolve('/lms', {}));
}
+11
View File
@@ -3,3 +3,14 @@
@import 'fumadocs-ui/css/preset.css';
@source "../../../packages/ui/src/**/*.{ts,tsx}";
/*
* The docs layout is nested inside HomeLayout, whose navbar is `sticky h-14 top-0`
* (3.5rem) but does not expose its height to the docs layout. Fumadocs hardcodes
* `--fd-docs-height: 100dvh`, so the sidebar and TOC end up 3.5rem taller than the
* visible area and their bottom (footer / last nav items) is clipped below the fold.
* Subtract the navbar height so both columns can scroll to the end.
*/
#nd-docs-layout {
--fd-docs-height: calc(100dvh - 3.5rem);
}