fix(auth): add captcha auto-refresh via ApolloLink (#12758)

- Introduced `createCaptchaRefreshLink` to trigger captcha token refresh
automatically.
- Removed redundant manual captcha refresh calls and integrated it into
Apollo Provider.
This commit is contained in:
Antoine Moreaux
2025-06-20 11:38:01 +02:00
committed by GitHub
parent fe5574fdf6
commit 2469c509a6
4 changed files with 76 additions and 63 deletions

View File

@ -0,0 +1,19 @@
import { ApolloLink } from '@apollo/client';
export const createCaptchaRefreshLink = (
requestFreshCaptchaToken: () => void,
) => {
return new ApolloLink((operation, forward) => {
const { variables } = operation;
const hasCaptchaToken = variables && 'captchaToken' in variables;
return forward(operation).map((response) => {
if (hasCaptchaToken) {
requestFreshCaptchaToken();
}
return response;
});
});
};