From c9fee0cad4e20faa812c8aff2b34ddf27f9cb431 Mon Sep 17 00:00:00 2001 From: Dominik Korsa Date: Thu, 21 Jan 2021 00:20:45 +0100 Subject: [PATCH] Add student picker window --- backend/src/routes/website-api/index.ts | 6 + .../website-api/resolvers/login-resolver.ts | 2 +- .../login-window.vue | 44 ++++-- .../students-window.vue | 125 ++++++++++++++++++ website/src/pages/authenticate-prompt/app.vue | 38 ++++-- website/src/types.ts | 11 +- 6 files changed, 206 insertions(+), 20 deletions(-) create mode 100644 website/src/compontents/authenticate-prompt-windows/students-window.vue diff --git a/backend/src/routes/website-api/index.ts b/backend/src/routes/website-api/index.ts index 0bbaf85..415dcee 100644 --- a/backend/src/routes/website-api/index.ts +++ b/backend/src/routes/website-api/index.ts @@ -45,6 +45,12 @@ export default async function registerWebsiteApi(server: MyFastifyInstance): Pro server.log.error(error); throw server.httpErrors.internalServerError(); } + // TODO: Find why the promise never resolves + reply.clearCookie(`epk-${request.query.prompt_id}`); + // In case execution of setCookie takes some time + // TODO: Remove + await new Promise((resolve) => setTimeout(resolve, 100)); + const sessionData = getSessionData(request.session); const prompt = sessionData.prompts.get(request.query.prompt_id); if (!prompt) throw server.httpErrors.badRequest('Prompt data not found'); diff --git a/backend/src/routes/website-api/resolvers/login-resolver.ts b/backend/src/routes/website-api/resolvers/login-resolver.ts index ed43c81..e6d7386 100644 --- a/backend/src/routes/website-api/resolvers/login-resolver.ts +++ b/backend/src/routes/website-api/resolvers/login-resolver.ts @@ -56,7 +56,7 @@ export default class LoginResolver { availableStudentIds: students.map(({ studentId }) => studentId), }; // TODO: Find why the promise never resolves - reply.setCookie('epk', encryptedPrivateKey, { + reply.setCookie(`epk-${promptId}`, encryptedPrivateKey, { sameSite: 'strict', httpOnly: true, path: '/', diff --git a/website/src/compontents/authenticate-prompt-windows/login-window.vue b/website/src/compontents/authenticate-prompt-windows/login-window.vue index 7b31c2e..a03f4ab 100644 --- a/website/src/compontents/authenticate-prompt-windows/login-window.vue +++ b/website/src/compontents/authenticate-prompt-windows/login-window.vue @@ -1,11 +1,22 @@ diff --git a/website/src/pages/authenticate-prompt/app.vue b/website/src/pages/authenticate-prompt/app.vue index 6eb9c5b..2269369 100644 --- a/website/src/pages/authenticate-prompt/app.vue +++ b/website/src/pages/authenticate-prompt/app.vue @@ -23,7 +23,7 @@