CLASSROOMIO-T-152: Student can join any course via invite link

This commit is contained in:
Rotimi Best
2023-09-14 12:47:26 +01:00
parent c07c119b5b
commit 14f58792f6
17 changed files with 320 additions and 137 deletions
@@ -0,0 +1,34 @@
import { redirect } from '@sveltejs/kit';
import { getCurrentOrg } from '$lib/utils/services/org';
import { getSupabase, supabase } from '$lib/utils/functions/supabase';
import { getProfile } from '$lib/utils/functions/user';
if (!supabase) {
getSupabase();
}
// 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 getCurrentOrg(orgSiteName, true);
const profile = await getProfile(email);
console.log('profile data', profile);
return {
orgId,
email,
currentOrg: _currentOrg,
profile
};
} catch (error) {
console.error('Error decoding invite params.hash', error);
throw redirect(301, '/404');
}
};