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