From b76dfba5a084d24145955981c6ef4d68a53cb838 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Wed, 27 Sep 2023 23:51:24 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(auth.py):=20decrease=20ACCES?= =?UTF-8?q?S=5FTOKEN=5FEXPIRE=5FMINUTES=20to=201=20minute=20for=20faster?= =?UTF-8?q?=20token=20expiration=20=F0=9F=90=9B=20fix(API/index.ts):=20add?= =?UTF-8?q?=20null=20check=20for=20response=20object=20in=20updateFlowInDa?= =?UTF-8?q?tabase=20function=20to=20prevent=20potential=20error=20?= =?UTF-8?q?=F0=9F=90=9B=20fix(formModal/index.tsx):=20close=20chat=20and?= =?UTF-8?q?=20websocket=20connection=20when=20user=20is=20redirected=20to?= =?UTF-8?q?=20login=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/controllers/API/index.ts | 8 ++++---- src/frontend/src/modals/formModal/index.tsx | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/frontend/src/controllers/API/index.ts b/src/frontend/src/controllers/API/index.ts index 80e97a73e..a4af5e6a4 100644 --- a/src/frontend/src/controllers/API/index.ts +++ b/src/frontend/src/controllers/API/index.ts @@ -1,4 +1,4 @@ -import { AxiosResponse } from "axios"; +import axios, { AxiosResponse } from "axios"; import { ReactFlowJsonObject } from "reactflow"; import { BASE_URL_API } from "../../constants/constants"; import { api } from "../../controllers/API/api"; @@ -146,8 +146,8 @@ export async function updateFlowInDatabase( description: updatedFlow.description, }); - if (response.status !== 200) { - throw new Error(`HTTP error! status: ${response.status}`); + if (response?.status !== 200) { + throw new Error(`HTTP error! status: ${response?.status}`); } return response.data; } catch (error) { @@ -522,4 +522,4 @@ export async function deleteApiKey(api_key: string) { console.log("Error:", error); throw error; } -} +} \ No newline at end of file diff --git a/src/frontend/src/modals/formModal/index.tsx b/src/frontend/src/modals/formModal/index.tsx index 89c7919af..49a03af57 100644 --- a/src/frontend/src/modals/formModal/index.tsx +++ b/src/frontend/src/modals/formModal/index.tsx @@ -156,6 +156,13 @@ export default function FormModal({ function handleOnClose(event: CloseEvent): void { if (isOpen.current) { + //check if the user has been logged out, if so close the chat when the user is redirected to the login page + if (window.location.href.includes("login")) { + setOpen(false); + ws.current?.close(); + return; + } + getBuildStatus(flow.id) .then((response) => { if (response.data.built) {