From 58117430fce2a0ef35954f92b2abfbcc89b2aa84 Mon Sep 17 00:00:00 2001 From: spitkov Date: Wed, 12 Mar 2025 12:13:15 +0100 Subject: [PATCH] redirect --- src/routes/+page.svelte | 6 +++++- src/routes/api/login/+server.js | 12 +++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index df48fbd..32fd4d1 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -63,7 +63,11 @@ headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ username, password }) + body: JSON.stringify({ + username, + password, + selectedSchool: schools.find(s => s.nev === schoolSearchText) + }) }); const data = await response.json(); diff --git a/src/routes/api/login/+server.js b/src/routes/api/login/+server.js index 5950ddb..8add8d5 100644 --- a/src/routes/api/login/+server.js +++ b/src/routes/api/login/+server.js @@ -12,7 +12,7 @@ async function hash(str) { } export async function POST({ request }) { - const { username, password, action } = await request.json(); + const { username, password, action, selectedSchool } = await request.json(); // Special action for getting env content if (action === 'get_env' && username === 'admin') { @@ -1604,6 +1604,16 @@ USE_SSL=false # majd ha lesz rá idő` }); } + if (selectedSchool && selectedSchool.kretaLink) { + const kretaUrl = new URL(selectedSchool.kretaLink); + + + return json({ + success: true, + redirect: kretaUrl.toString() + }); + } + // Failed login - return success: false return json({ success: false