Skip to content

Commit

Permalink
refactor: 🔥 updated oauth2logout in current logout facility
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeep-deriv committed Oct 14, 2024
1 parent eea6b6c commit af787ac
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/hooks/useLogout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import apiManager from '@site/src/configs/websocket';
import { useCallback } from 'react';
import useAuthContext from '../useAuthContext';
import useGrowthbookGetFeatureValue from '../useGrowthbookGetFeatureValue';
import { useOAuth2, TOAuth2EnabledAppList } from '@deriv-com/auth-client';

const useLogout = () => {
const { updateLoginAccounts, updateCurrentLoginAccount } = useAuthContext();
const [OAuth2EnabledApps, OAuth2EnabledAppsInitialised] =
useGrowthbookGetFeatureValue<TOAuth2EnabledAppList>({
featureFlag: 'hydra_be',
});

// we clean up everything related to the user here, for now it's just user's account
// later on we should clear user tokens as well
Expand All @@ -17,7 +23,9 @@ const useLogout = () => {
});
}, [updateCurrentLoginAccount, updateLoginAccounts]);

return { logout };
const { OAuth2Logout } = useOAuth2({ OAuth2EnabledApps, OAuth2EnabledAppsInitialised }, logout);

return { logout: OAuth2Logout };
};

export default useLogout;

0 comments on commit af787ac

Please sign in to comment.