diff --git a/airbyte-webapp/src/packages/cloud/services/auth/AuthService.tsx b/airbyte-webapp/src/packages/cloud/services/auth/AuthService.tsx index d62714cd5b9d..248154205c21 100644 --- a/airbyte-webapp/src/packages/cloud/services/auth/AuthService.tsx +++ b/airbyte-webapp/src/packages/cloud/services/auth/AuthService.tsx @@ -1,5 +1,5 @@ import { User as FirebaseUser } from "firebase/auth"; -import React, { useCallback, useContext, useMemo, useRef } from "react"; +import React, { useCallback, useContext, useEffect, useMemo, useRef } from "react"; import { useQueryClient } from "react-query"; import { useEffectOnce } from "react-use"; import { Observable, Subject } from "rxjs"; @@ -160,6 +160,23 @@ export const AuthenticationProvider: React.FC> }); }); + useEffect(() => { + const onFocus = async () => { + return auth.onAuthStateChanged(async (currentUser) => { + if (!currentUser) { + loggedOut(); + } else { + await onAfterAuth(currentUser); + } + }); + }; + + window.addEventListener("focus", onFocus); + return () => { + window.removeEventListener("focus", onFocus); + }; + }, [auth, loggedOut, onAfterAuth]); + const queryClient = useQueryClient(); const ctx: AuthContextApi = useMemo( diff --git a/airbyte-webapp/src/packages/cloud/views/auth/Auth.tsx b/airbyte-webapp/src/packages/cloud/views/auth/Auth.tsx index d614f6dfd520..f4852fd0f305 100644 --- a/airbyte-webapp/src/packages/cloud/views/auth/Auth.tsx +++ b/airbyte-webapp/src/packages/cloud/views/auth/Auth.tsx @@ -54,7 +54,13 @@ export const Auth: React.FC = () => { } /> } + element={ + + } />