feat(api): added login redirect

This commit is contained in:
Alexander 2024-06-13 16:10:19 +02:00
parent 2b76b00e9a
commit 07ee332b4c
2 changed files with 7 additions and 2 deletions

View file

@ -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)
return users.authenticate_sso(email, email)

View file

@ -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