From 1baaefc68b22b33340205bc0e85dba150b6c1437 Mon Sep 17 00:00:00 2001 From: Lord Lumineer Date: Thu, 9 May 2024 15:28:39 -0400 Subject: [PATCH] fix redirect --- client/components/loginForm.vue | 4 ++-- client/components/registerForm.vue | 4 ++-- docker-compose-FULL_SECRET.yml | 1 - server/assets/html/template/login.html | 4 ++-- server/assets/html/template/register.html | 4 ++-- server/main.py | 7 +++++++ 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/client/components/loginForm.vue b/client/components/loginForm.vue index 054d663..63ba8d1 100644 --- a/client/components/loginForm.vue +++ b/client/components/loginForm.vue @@ -91,10 +91,10 @@ async function onSubmit(event: FormSubmitEvent) { const stateParam = currentUri.searchParams.get("state"); window.localStorage.setItem("token", data.access_token); if (redirectUri) { - window.location.href = `https://eventkit.stream/landing?access_token=${data.access_token}&token_type=${data.token_type}`; + window.location.href = `${redirectUri}?token_type=${data.token_type}&access_token=${data.access_token}&state=${stateParam}`; return; } - window.location.href = `${redirectUri}?access_token=${data.access_token}&token_type=${data.token_type}&state=${stateParam}`; + window.location.href = `https://eventkit.stream/landing?token_type=${data.token_type}&access_token=${data.access_token}`; } else { isLoading.value = false; alert("Login Failed: " + data.detail); diff --git a/client/components/registerForm.vue b/client/components/registerForm.vue index ce3d25f..13bb790 100644 --- a/client/components/registerForm.vue +++ b/client/components/registerForm.vue @@ -169,10 +169,10 @@ async function onSubmit(event: FormSubmitEvent) { const stateParam = currentUri.searchParams.get("state"); window.localStorage.setItem("token", data.access_token); if (redirectUri) { - window.location.href = `https://eventkit.stream/landing?access_token=${data.access_token}&token_type=${data.token_type}`; + window.location.href = `${redirectUri}?token_type=${data.token_type}&access_token=${data.access_token}&state=${stateParam}`; return; } - window.location.href = `${redirectUri}?access_token=${data.access_token}&token_type=${data.token_type}&state=${stateParam}`; + window.location.href = `https://eventkit.stream/landing?token_type=${data.token_type}&access_token=${data.access_token}`; } else { isLoading.value = false; alert("Login Failed: " + data.detail); diff --git a/docker-compose-FULL_SECRET.yml b/docker-compose-FULL_SECRET.yml index ed87532..ef2e3c5 100644 --- a/docker-compose-FULL_SECRET.yml +++ b/docker-compose-FULL_SECRET.yml @@ -1,4 +1,3 @@ -version: '3.8' services: auth-server: depends_on: diff --git a/server/assets/html/template/login.html b/server/assets/html/template/login.html index 2ae7929..67bf335 100644 --- a/server/assets/html/template/login.html +++ b/server/assets/html/template/login.html @@ -210,9 +210,9 @@ .then((data) => { if (data.access_token) { if (redirectUri) { - window.location.href = `${redirectUri}?access_token=${data.access_token}&expires_in=${data.expires_in}&token_type=${data.token_type}&state=${state}`; + window.location.href = `${redirectUri}?token_type=${data.token_type}&access_token=${data.access_token}&state=${stateParam}`; } - window.location.href = `https://eventkit.stream/landing?access_token=${access_token}&token_type=${token_type}`; + window.location.href = `https://eventkit.stream/landing?token_type=${data.token_type}&access_token=${data.access_token}`; } else { loginButton.disabled = false; loginButton.innerHTML = originalButtonText; diff --git a/server/assets/html/template/register.html b/server/assets/html/template/register.html index b13d3ea..da9f4bd 100644 --- a/server/assets/html/template/register.html +++ b/server/assets/html/template/register.html @@ -268,9 +268,9 @@ .then((data) => { if (data.access_token) { if (redirectUri) { - window.location.href = `${redirectUri}?access_token=${data.access_token}&expires_in=${data.expires_in}&token_type=${data.token_type}&state=${state}`; + window.location.href = `${redirectUri}?token_type=${data.token_type}&access_token=${data.access_token}&state=${stateParam}`; } - window.location.href = `https://eventkit.stream/landing?access_token=${access_token}&token_type=${token_type}`; + window.location.href = `https://eventkit.stream/landing?token_type=${data.token_type}&access_token=${data.access_token}`; } else { signupButton.disabled = false; signupButton.innerHTML = originalButtonText; diff --git a/server/main.py b/server/main.py index 28d04a7..ae14cda 100644 --- a/server/main.py +++ b/server/main.py @@ -163,6 +163,13 @@ def custom_generate_unique_id(route: APIRoute) -> str: app.include_router(api_router, prefix=settings.API_STR) +@app.get("/", include_in_schema=False, tags=["misc"]) +async def root(): + """Root endpoint for the API.""" + return RedirectResponse( + url=f"/authorize", + status_code=status.HTTP_307_TEMPORARY_REDIRECT, + ) @app.get("/favicon.ico", include_in_schema=False, tags=["misc"]) async def favicon():