From 39917b4e2aafb15b91ad8ce41492e3cd08168d81 Mon Sep 17 00:00:00 2001 From: Mirlan Date: Mon, 27 Sep 2021 20:47:34 +0600 Subject: [PATCH] fix(1587): redirect to auth provider on callback error (#506) --- src/features/AuthStore/hooks/useAuth.tsx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/features/AuthStore/hooks/useAuth.tsx b/src/features/AuthStore/hooks/useAuth.tsx index 3ba473fb..db7793df 100644 --- a/src/features/AuthStore/hooks/useAuth.tsx +++ b/src/features/AuthStore/hooks/useAuth.tsx @@ -75,16 +75,18 @@ export const useAuth = () => { validator: isString, }) - const signinRedirectCallback = useCallback(async () => { - const loadedUser = await userManager.signinRedirectCallback() - storeUser(loadedUser) - queryParamStorage.clear() - history.replace(PAGES.home) - markUserLoaded() - if (matchPage) { - history.push(matchPage) - setMatchPage('') - } + const signinRedirectCallback = useCallback(() => { + userManager.signinRedirectCallback() + .then((loadedUser) => { + storeUser(loadedUser) + queryParamStorage.clear() + history.replace(PAGES.home) + markUserLoaded() + if (matchPage) { + history.push(matchPage) + setMatchPage('') + } + }).catch(login) }, [ userManager, history, @@ -92,6 +94,7 @@ export const useAuth = () => { storeUser, markUserLoaded, matchPage, + login, ]) useEffect(() => {