improve layout.server
This commit is contained in:
@@ -12,29 +12,22 @@ interface LoadOutput {
|
|||||||
orgSiteName: string;
|
orgSiteName: string;
|
||||||
isOrgSite: boolean;
|
isOrgSite: boolean;
|
||||||
skipAuth: boolean;
|
skipAuth: boolean;
|
||||||
org: CurrentOrg;
|
org: CurrentOrg | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const load = async ({ url, cookies }): Promise<LoadOutput> => {
|
export const load = async ({ url, cookies }): Promise<LoadOutput> => {
|
||||||
// if (url.hostname === 'classroomio.com') {
|
const response: LoadOutput = {
|
||||||
// throw redirect(301, 'https://about.classroomio.com');
|
|
||||||
// }
|
|
||||||
|
|
||||||
let response: LoadOutput = {
|
|
||||||
orgSiteName: '',
|
orgSiteName: '',
|
||||||
isOrgSite: false,
|
isOrgSite: false,
|
||||||
skipAuth: false,
|
skipAuth: false,
|
||||||
org: {
|
org: null
|
||||||
theme: ''
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const _orgSiteName = cookies.get('_orgSiteName');
|
const _orgSiteName = cookies.get('_orgSiteName');
|
||||||
const debugPlay = cookies.get('debugPlay');
|
const debugPlay = cookies.get('debugPlay');
|
||||||
const debugMode = _orgSiteName && _orgSiteName !== 'false';
|
const debugMode = _orgSiteName && _orgSiteName !== 'false';
|
||||||
console.log('_orgSiteName', _orgSiteName);
|
|
||||||
|
|
||||||
const matches = url.host.match(/([a-z 0-9 \-]+).*classroomio[.]com/);
|
const matches = url.host.match(/([a-z 0-9 -]+).*classroomio[.]com/);
|
||||||
const subdomain = matches?.[1] ?? '';
|
const subdomain = matches?.[1] ?? '';
|
||||||
|
|
||||||
if (!blockedSubdomain.includes(subdomain)) {
|
if (!blockedSubdomain.includes(subdomain)) {
|
||||||
@@ -42,7 +35,7 @@ export const load = async ({ url, cookies }): Promise<LoadOutput> => {
|
|||||||
|
|
||||||
response.isOrgSite = debugMode || answer;
|
response.isOrgSite = debugMode || answer;
|
||||||
response.orgSiteName = debugMode ? _orgSiteName : subdomain;
|
response.orgSiteName = debugMode ? _orgSiteName : subdomain;
|
||||||
response.org = await getCurrentOrg(response.orgSiteName, true);
|
response.org = (await getCurrentOrg(response.orgSiteName, true)) || null;
|
||||||
} else if (subdomain === 'play' || debugPlay === 'true') {
|
} else if (subdomain === 'play' || debugPlay === 'true') {
|
||||||
response.skipAuth = true;
|
response.skipAuth = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user