Fix invalid token after credentials change (#4717)

- If sync fails we set authFailedAt
- This information is displayed in the frontend in accounts with a `Sync
Failed` pill
- The user can reconnect his account in the dropdown menu
- A new OAuth flow is triggered
- The account is synced
This commit is contained in:
bosiraphael
2024-04-02 11:32:27 +02:00
committed by GitHub
parent a3a15957f4
commit ffb1733f39
18 changed files with 318 additions and 123 deletions

View File

@ -0,0 +1,21 @@
import { useCallback } from 'react';
import { REACT_APP_SERVER_BASE_URL } from '~/config';
import { useGenerateTransientTokenMutation } from '~/generated/graphql';
export const useTriggerGoogleApisOAuth = () => {
const [generateTransientToken] = useGenerateTransientTokenMutation();
const triggerGoogleApisOAuth = useCallback(async () => {
const authServerUrl = REACT_APP_SERVER_BASE_URL;
const transientToken = await generateTransientToken();
const token =
transientToken.data?.generateTransientToken.transientToken.token;
window.location.href = `${authServerUrl}/auth/google-gmail?transientToken=${token}`;
}, [generateTransientToken]);
return { triggerGoogleApisOAuth };
};