CLASSROOMIO-T-126: Invite teacher and teacher can login

This commit is contained in:
Rotimi Best
2023-09-01 15:28:47 +01:00
parent 9d0fd56f05
commit 929edea63c
29 changed files with 498 additions and 74 deletions
+28
View File
@@ -0,0 +1,28 @@
import { supabase } from '$lib/utils/functions/supabase';
export async function sendInvite(email: string, org: any) {
const { data } = await supabase.auth.getSession();
const accessToken = data.session?.access_token || '';
try {
const response = await fetch('/api/email/invite', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: accessToken
},
body: JSON.stringify({
email,
org
})
});
if (!response.ok) {
throw new Error(await response.text());
}
const result = await response.json();
console.log('Sent invite email', result);
} catch (error) {
console.error('Error sending invite email', error);
}
}