|
|
|
@ -158,6 +158,8 @@ export const useAuth = () => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const signinRedirectCallback = useCallback(() => { |
|
|
|
const signinRedirectCallback = useCallback(() => { |
|
|
|
|
|
|
|
setPage(history.location.pathname) |
|
|
|
|
|
|
|
|
|
|
|
userManager.signinRedirectCallback() |
|
|
|
userManager.signinRedirectCallback() |
|
|
|
.then((loadedUser) => { |
|
|
|
.then((loadedUser) => { |
|
|
|
storeUser(loadedUser) |
|
|
|
storeUser(loadedUser) |
|
|
|
@ -171,7 +173,6 @@ export const useAuth = () => { |
|
|
|
markUserLoaded() |
|
|
|
markUserLoaded() |
|
|
|
setPage('') |
|
|
|
setPage('') |
|
|
|
setSearch('') |
|
|
|
setSearch('') |
|
|
|
// }
|
|
|
|
|
|
|
|
}).catch(login) |
|
|
|
}).catch(login) |
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, [ |
|
|
|
}, [ |
|
|
|
@ -181,7 +182,13 @@ export const useAuth = () => { |
|
|
|
]) |
|
|
|
]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
const isRedirectedBackFromAuthProvider = history.location.pathname === '/redirect' |
|
|
|
const urlSearch = new URLSearchParams(history.location.search) |
|
|
|
|
|
|
|
const searchToken = urlSearch.get('access_token') |
|
|
|
|
|
|
|
const searchRefToken = urlSearch.get('id_token') |
|
|
|
|
|
|
|
const searchExp = urlSearch.get('expires_in') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isRedirectedBackFromAuthProvider = Boolean(searchToken && searchRefToken && searchExp) |
|
|
|
|
|
|
|
|
|
|
|
isRedirectedBackFromAuthProvider ? signinRedirectCallback() : checkUser() |
|
|
|
isRedirectedBackFromAuthProvider ? signinRedirectCallback() : checkUser() |
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, [ |
|
|
|
}, [ |
|
|
|
|