Skip to content

Commit

Permalink
fix: missing hook dependencies + warning logs in performAuth hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Jul 18, 2024
1 parent 9335ff0 commit b302dae
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/performAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ const useDefaultAuthCodeCallback = (
const { authCallbackUrl, clientId } = useBentoAuthContext();

return useCallback(async (code: string, verifier: string) => {
if (!authCallbackUrl || !clientId) {
logMissingAuthContext("authCallbackUrl", "clientId");
return;
}

const lastPath = popLocalStorageItem(LS_BENTO_POST_AUTH_REDIRECT);
await dispatch(tokenHandoff({ code, verifier, clientId, authCallbackUrl }));
navigate(lastPath ?? DEFAULT_REDIRECT, { replace: true });
Expand All @@ -99,6 +104,8 @@ export const useHandleCallback = (
const defaultAuthCodeCallback = useDefaultAuthCodeCallback(onSuccessfulAuthentication);

useEffect(() => {
// Not used directly in this effect, but if we don't have it our auth callback / token handoff presumably won't
// work properly, so we terminate early.
if (!authCallbackUrl || !clientId) {
logMissingAuthContext("authCallbackUrl", "clientId");
return;
Expand Down Expand Up @@ -153,7 +160,18 @@ export const useHandleCallback = (
console.error(err);
setLSNotSignedIn();
});
}, [location, navigate, oidcConfig, defaultAuthCodeCallback, isAuthenticated]);
}, [
authCallbackUrl,
authCodeCallback,
callbackPath,
clientId,
defaultAuthCodeCallback,
isAuthenticated,
location,
navigate,
oidcConfig,
uiErrorCallback,
]);
};

export const checkIsInAuthPopup = (applicationUrl: string): boolean => {
Expand Down

0 comments on commit b302dae

Please sign in to comment.