chore: add user_id to response header
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { validateUser } from '$lib/utils/services/middlewares';
|
|
||||||
import type { Handle } from '@sveltejs/kit';
|
import type { Handle } from '@sveltejs/kit';
|
||||||
|
import { validateUser } from '$lib/utils/services/middlewares';
|
||||||
|
|
||||||
const PUBLIC_ROUTES = [
|
const PUBLIC_ROUTES = [
|
||||||
'/api/completion',
|
'/api/completion',
|
||||||
@@ -30,7 +30,9 @@ export const handle: Handle = async ({ event, resolve }) => {
|
|||||||
|
|
||||||
const accessToken = event.request.headers.get('Authorization')!;
|
const accessToken = event.request.headers.get('Authorization')!;
|
||||||
|
|
||||||
await validateUser(accessToken);
|
const user = await validateUser(accessToken);
|
||||||
|
|
||||||
|
response.headers.set('user_id', `${user.id}`);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
import { get } from 'svelte/store';
|
import type { Course, Lesson, Profile } from '$lib/utils/types';
|
||||||
|
|
||||||
import type { PostgrestError } from '@supabase/supabase-js';
|
import type { PostgrestError } from '@supabase/supabase-js';
|
||||||
import { supabase } from '$lib/utils/functions/supabase';
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { addGroupMember } from './index';
|
import { QUESTION_TYPE } from '$lib/components/Question/constants';
|
||||||
// @ts-ignore
|
|
||||||
import { profile } from '$lib/utils/store/user';
|
|
||||||
import type { Course, Exercise, Lesson, Profile } from '$lib/utils/types';
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { ROLE } from '$lib/utils/constants/roles';
|
import { ROLE } from '$lib/utils/constants/roles';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { QUESTION_TYPE } from '$lib/components/Question/constants';
|
import { addGroupMember } from './index';
|
||||||
|
import { get } from 'svelte/store';
|
||||||
|
// @ts-ignore
|
||||||
|
import { profile } from '$lib/utils/store/user';
|
||||||
|
import { supabase } from '$lib/utils/functions/supabase';
|
||||||
|
|
||||||
type GetCourseResponse = {
|
type GetCourseResponse = {
|
||||||
data: Course;
|
data: Course;
|
||||||
@@ -199,7 +200,7 @@ export async function cloneCourse(courseId: string, newTitle: string): Promise<C
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 1. Copy course table
|
* 1. Copy course table
|
||||||
* 2. Copy lessons table
|
* 2. Copy lessons table (NOTE: Copy sections table here)
|
||||||
* 3. Copy exercises table
|
* 3. Copy exercises table
|
||||||
* 4. Copy questions table
|
* 4. Copy questions table
|
||||||
* 5. Copy options table
|
* 5. Copy options table
|
||||||
|
|||||||
Reference in New Issue
Block a user