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

32 lines
880 B
TypeScript
Raw Normal View History

import { OrgApiServer } from '$lib/features/org/api/org.server';
import { getProfile } from '$lib/utils/functions/user';
import { redirect } from '@sveltejs/kit';
// we need to know if the email exists or not.
// with this we can only ask the user to accept
export const load = async ({ params = { hash: '' } }) => {
try {
const hashData = atob(decodeURIComponent(params.hash));
console.log('hashData', hashData);
const { orgId, email, orgSiteName } = JSON.parse(hashData);
const currentOrg = await OrgApiServer.getOrgBySiteName(orgSiteName);
const profile = await getProfile(email);
console.log('profile data', profile);
return {
2024-09-17 14:24:37 +01:00
invite: {
orgId,
email,
currentOrg,
profile
}
};
} catch (error) {
console.error('Error decoding invite params.hash', error);
2025-11-01 15:49:29 +01:00
redirect(307, '/404');
}
};