From 0d32c93787a74536ea17c51123ff8f086ffb9f57 Mon Sep 17 00:00:00 2001 From: Markus Brueckner Date: Sun, 26 Jan 2025 22:08:07 +0100 Subject: [PATCH] fix survey creation issue This fixes an issue where the user would create a new survey and due to a missing await, the permissions would never get stored --- src/routes/(app)/survey/new/+page.server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/(app)/survey/new/+page.server.ts b/src/routes/(app)/survey/new/+page.server.ts index ec560c2..a1848a4 100644 --- a/src/routes/(app)/survey/new/+page.server.ts +++ b/src/routes/(app)/survey/new/+page.server.ts @@ -23,7 +23,7 @@ export const actions = { default: async (event) => { const owner = event.locals.userId; if (!owner) { - error(400, 'User is not logged in'); + error(403, 'User is not logged in'); } const formData = await event.request.formData(); @@ -44,7 +44,7 @@ export const actions = { const surveyId = ids[0].id as SurveyId; // insert the owner permission for this survey - db.insert(surveyPermissionsTable).values({ surveyId, user: owner, access: AccessLevel.Owner }); + await db.insert(surveyPermissionsTable).values({ surveyId, user: owner, access: AccessLevel.Owner }); // record all participants & skills for (const participant of participants) { await addParticipant(surveyId, participant);