From 07ee332b4c138e41421153164dc6716b698880d4 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 13 Jun 2024 16:10:19 +0200 Subject: [PATCH] feat(api): added login redirect --- ee/api/chalicelib/core/signup.py | 2 +- ee/api/routers/core_dynamic.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ee/api/chalicelib/core/signup.py b/ee/api/chalicelib/core/signup.py index 2aaa37641..4e39283f7 100644 --- a/ee/api/chalicelib/core/signup.py +++ b/ee/api/chalicelib/core/signup.py @@ -178,4 +178,4 @@ async def create_oauth_tenant(fullname: str, email: str): cur.execute(cur.mogrify(query, params)) r = cur.fetchone() - return users.authenticate_sso(email, email) \ No newline at end of file + return users.authenticate_sso(email, email) diff --git a/ee/api/routers/core_dynamic.py b/ee/api/routers/core_dynamic.py index c9af327e0..962358199 100644 --- a/ee/api/routers/core_dynamic.py +++ b/ee/api/routers/core_dynamic.py @@ -114,9 +114,14 @@ if True or config("MULTI_TENANTS", cast=bool, default=False) or not tenants.tena content = await signup.create_oauth_tenant(name, email) if "errors" in content: return content + if content is None: + return {"errors": ["null JWT"]} + refresh_token = content.pop("refreshToken") refresh_token_max_age = content.pop("refreshTokenMaxAge") - response = JSONResponse(content=content) + response = Response( + status_code=status.HTTP_302_FOUND, + headers={'Location': config("SITE_URL") + "/login?jwt=" + content}) response.set_cookie(key="refreshToken", value=refresh_token, path="/api/refresh", max_age=refresh_token_max_age, secure=True, httponly=True) return response