Skip to content

Commit

Permalink
fix: logout; entity detail page needs the page to refresh due to comp…
Browse files Browse the repository at this point in the history
…lex shouldfetchentity (#178)
  • Loading branch information
Fran McDade authored and Fran McDade committed Jan 5, 2025
1 parent 76666fb commit d2189df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/hooks/useFetchEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const useFetchEntity = <T,>(
() =>
isFetchRequired(
exploreMode !== EXPLORE_MODE.CS_FETCH_CS_FILTERING,
Boolean(token),
Boolean(token), // TODO(cc), note a fetch is required if the token is true, but is unable to re-fetch on logout when token is undefined! Page is required to reload!
Boolean(catalogState),
Boolean(entityResponse)
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Router from "next/router";
import { useRouter } from "next/router";
import { useCallback } from "react";
import { useProviders } from "../../../hooks/authentication/providers/useProviders";
import { Service } from "../../authentication/auth/types";
Expand All @@ -8,6 +8,7 @@ import { service } from "../service/service";

export const useGoogleSignInService = (reducer: SessionReducer): Service => {
const { findProvider } = useProviders();
const { basePath } = useRouter();
const {
authenticationReducer: { authenticationDispatch },
authReducer: { authDispatch },
Expand Down Expand Up @@ -36,10 +37,16 @@ export const useGoogleSignInService = (reducer: SessionReducer): Service => {
credentialsDispatch,
tokenDispatch,
});
if (!options?.callbackUrl) return;
Router.push(options?.callbackUrl).catch((e) => console.error(e));
// Request page reload, ensuring that the entity detail page is re-initialized with the correct state and associated data.
location.href = options?.callbackUrl || basePath;
},
[authDispatch, authenticationDispatch, credentialsDispatch, tokenDispatch]
[
authDispatch,
authenticationDispatch,
basePath,
credentialsDispatch,
tokenDispatch,
]
);

return { requestLogin: onLogin, requestLogout: onLogout };
Expand Down

0 comments on commit d2189df

Please sign in to comment.