From 8b8494ee645ed745e399a03032b4d8171e30a2e4 Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Sun, 16 Jun 2024 18:53:08 -0300 Subject: [PATCH] organize code --- src/main/services/hydra-api.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/services/hydra-api.ts b/src/main/services/hydra-api.ts index 83af3cae..1fcb937e 100644 --- a/src/main/services/hydra-api.ts +++ b/src/main/services/hydra-api.ts @@ -99,14 +99,17 @@ export class HydraApi { err instanceof AxiosError && (err?.response?.status === 401 || err?.response?.status === 403) ) { - this.userAuth.authToken = ""; - this.userAuth.expirationTimestamp = 0; + this.userAuth = { + authToken: "", + expirationTimestamp: 0, + refreshToken: "", + }; + + userAuthRepository.delete({ id: 1 }); if (WindowManager.mainWindow) { WindowManager.mainWindow.webContents.send("on-signout"); } - - userAuthRepository.delete({ id: 1 }); } throw err; @@ -132,12 +135,12 @@ export class HydraApi { return this.instance.post(url, data, this.getAxiosConfig()); } - static async put(url, data?: any) { + static async put(url: string, data?: any) { await this.revalidateAccessTokenIfExpired(); return this.instance.put(url, data, this.getAxiosConfig()); } - static async patch(url, data?: any) { + static async patch(url: string, data?: any) { await this.revalidateAccessTokenIfExpired(); return this.instance.patch(url, data, this.getAxiosConfig()); }