Files
classroomio/apps/dashboard/src/routes/invite/s/[hash]/+layout.server.ts
T

28 lines
741 B
TypeScript
Raw Normal View History

import { OrgApiServer } from '$features/org/api/org.server';
import { redirect } from '@sveltejs/kit';
export const load = async ({ params = { hash: '' } }) => {
try {
const courseHashData = atob(decodeURIComponent(params.hash));
console.log('courseHashData', courseHashData);
2024-07-10 21:53:34 +01:00
const { id, name, description, orgSiteName } = JSON.parse(courseHashData);
2024-07-10 21:53:34 +01:00
if (!id || !name || !description || !orgSiteName) {
throw 'Validation failed';
}
const currentOrg = await OrgApiServer.getOrgBySiteName(orgSiteName);
return {
2024-07-10 21:53:34 +01:00
id,
name,
description,
currentOrg
};
} catch (error) {
console.error('Error decoding course invite params.hash', error);
2025-11-01 15:49:29 +01:00
redirect(307, '/404');
}
};