From 2199c17225480bf271ebc050083b68c46f89f0c0 Mon Sep 17 00:00:00 2001 From: Fran McDade Date: Mon, 4 Nov 2024 10:44:30 +1000 Subject: [PATCH] refactor: auth status settled value (#178) --- src/hooks/authentication/session/useSessionActive.ts | 2 +- src/hooks/authentication/session/useSessionAuth.ts | 4 ++-- src/providers/authentication/auth/types.ts | 2 +- src/providers/googleSignInAuthentication/contants.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hooks/authentication/session/useSessionActive.ts b/src/hooks/authentication/session/useSessionActive.ts index 66f5de2..cb14c6c 100644 --- a/src/hooks/authentication/session/useSessionActive.ts +++ b/src/hooks/authentication/session/useSessionActive.ts @@ -13,7 +13,7 @@ export const useSessionActive = (authState: AuthState): void => { const { status } = authState; const { callbackUrl } = useRouteHistory(2); useEffect(() => { - if (status !== AUTH_STATUS.DONE) return; + if (status !== AUTH_STATUS.SETTLED) return; Router.push(callbackUrl(transformRoute)); }, [callbackUrl, status]); }; diff --git a/src/hooks/authentication/session/useSessionAuth.ts b/src/hooks/authentication/session/useSessionAuth.ts index 81cabfc..6e16a91 100644 --- a/src/hooks/authentication/session/useSessionAuth.ts +++ b/src/hooks/authentication/session/useSessionAuth.ts @@ -43,7 +43,7 @@ function getSession( switch (status) { case AUTH_STATUS.PENDING: return { isAuthenticated: false, status }; - case AUTH_STATUS.DONE: + case AUTH_STATUS.SETTLED: return { isAuthenticated, status }; default: return { isAuthenticated: false, status }; @@ -57,5 +57,5 @@ function getSession( */ function getSessionStatus(status: AUTHENTICATION_STATUS): AUTH_STATUS { if (status === AUTHENTICATION_STATUS.PENDING) return AUTH_STATUS.PENDING; - return AUTH_STATUS.DONE; + return AUTH_STATUS.SETTLED; } diff --git a/src/providers/authentication/auth/types.ts b/src/providers/authentication/auth/types.ts index 9b21dec..44b009b 100644 --- a/src/providers/authentication/auth/types.ts +++ b/src/providers/authentication/auth/types.ts @@ -37,8 +37,8 @@ export interface Service { } export enum AUTH_STATUS { - DONE = "DONE", PENDING = "PENDING", + SETTLED = "SETTLED", } export interface UpdateAuthStateAction { diff --git a/src/providers/googleSignInAuthentication/contants.ts b/src/providers/googleSignInAuthentication/contants.ts index 1061dac..86695a5 100644 --- a/src/providers/googleSignInAuthentication/contants.ts +++ b/src/providers/googleSignInAuthentication/contants.ts @@ -8,7 +8,7 @@ import { export const AUTH_STATE: AuthState = { ...DEFAULT_AUTH_STATE, - status: AUTH_STATUS.DONE, + status: AUTH_STATUS.SETTLED, }; export const AUTHENTICATION_STATE: AuthenticationState = {