Skip to content

Commit 909f0f7

Browse files
fix: prevent multiple simultaneous executions in OAuth callback handling
1 parent 8884930 commit 909f0f7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app/auth/callback/page.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ function AuthCallbackContent() {
1414
"loading",
1515
);
1616
const [message, setMessage] = useState("");
17+
const [isProcessing, setIsProcessing] = useState(false);
1718

1819
useEffect(() => {
1920
const handleCallback = async () => {
21+
// Prevent multiple simultaneous executions
22+
if (isProcessing) return;
23+
setIsProcessing(true);
24+
2025
try {
2126
// Check if this is an OAuth callback
2227
const success = searchParams.get("success");
@@ -67,11 +72,14 @@ function AuthCallbackContent() {
6772
"An error occurred during authentication. Please try again.",
6873
);
6974
setTimeout(() => router.push("/"), 3000);
75+
} finally {
76+
setIsProcessing(false);
7077
}
7178
};
7279

7380
handleCallback();
74-
}, [router, searchParams, refreshUser]);
81+
// eslint-disable-next-line react-hooks/exhaustive-deps
82+
}, [searchParams]);
7583

7684
if (status === "loading") {
7785
return (

0 commit comments

Comments
 (0)