fix(dashboard): redirect students on app domain to org LMS (#675)

* fix(dashboard): redirect students on app domain to org LMS

When a student logs in on app.classroomio.com, send them to their org
tenant domain with a full page reload instead of staying on /lms at the
app host. Org sites and self-hosted installs keep the existing behavior.

Students who explicitly open /onboarding while already belonging to an
org are no longer redirected away, so they can still create their own
academy with the same email.

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

* refactor(dashboard): use getOrgPublicUrl instead of duplicate helper

Main added getOrgPublicOrigin for tenant URLs; extend it with
getOrgPublicUrl for path-based redirects and drop the parallel
getOrgSiteUrl helper from org utils.

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

---------
This commit is contained in:
Rotimi Best
2026-06-21 17:42:02 +01:00
committed by GitHub
co-authored by Rotimi Best
parent 5320f1eb44
commit 3547901de6
2 changed files with 37 additions and 3 deletions
+20
View File
@@ -104,6 +104,26 @@ export function getOrgPublicOrigin(org: OrgPublicOrigin): string {
return browser ? window.location.origin : '';
}
/** Absolute URL on an org's public tenant site (e.g. `/lms`, `/course/{slug}`). Client-only. */
export function getOrgPublicUrl(org: OrgPublicOrigin, pathname = '/'): string {
if (!browser) {
return pathname;
}
const origin = getOrgPublicOrigin(org);
if (!origin) {
return pathname;
}
const url = new URL(pathname, origin);
if (window.location.host.includes('localhost') && org.siteName) {
url.searchParams.set('org', org.siteName);
}
return url.toString();
}
export const currentOrgDomain = derived(currentOrg, ($currentOrg) => getOrgPublicOrigin($currentOrg));
export const isFreePlan = derived(currentOrg, ($currentOrg) => {