Skip to content

Commit

Permalink
fix(auth): checks for cf error more generally
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrishajev committed Jan 29, 2025
1 parent 4ab17f2 commit c35effc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/deploy-web/src/components/turnstile/Turnstile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FC, useCallback, useEffect, useMemo, useRef, useState } from "react";
import { MdInfo } from "react-icons/md";
import { Button } from "@akashnetwork/ui/components";
import { Turnstile as ReactTurnstile, TurnstileInstance } from "@marsidev/react-turnstile";
import axios, { AxiosError, AxiosHeaders } from "axios";
import axios, { AxiosError } from "axios";
import { motion } from "framer-motion";
import { firstValueFrom, Subject } from "rxjs";

Expand All @@ -25,9 +25,9 @@ export const Turnstile: FC = () => {
const interceptorId = managedWalletHttpService.interceptors.response.use(
response => response,
async (error: AxiosError) => {
const headers = error.response?.headers;
const request = error?.request;

if (headers instanceof AxiosHeaders && headers.get("cf-mitigated") === "challenge" && turnstileRef.current) {
if (request?.status === 0 && turnstileRef.current) {
turnstileRef.current?.render();
turnstileRef.current.execute();
const response = await Promise.race([turnstileRef.current.getResponsePromise(), firstValueFrom(dismissedSubject.current.asObservable())]);
Expand Down

0 comments on commit c35effc

Please sign in to comment.