diff --git a/apps/web/src/pages/auth/hooks/useSocialLogin.ts b/apps/web/src/pages/auth/hooks/useSocialLogin.ts index ba42605e..cdbff809 100644 --- a/apps/web/src/pages/auth/hooks/useSocialLogin.ts +++ b/apps/web/src/pages/auth/hooks/useSocialLogin.ts @@ -1,4 +1,4 @@ -import { useCallback } from 'react'; +import { useCallback, useRef } from 'react'; import { useKakaoLogin } from '@/features/auth/model'; @@ -28,7 +28,24 @@ export const useSocialLogin = () => { } }; + const isDisabledRef = useRef(false); + const timeoutRef = useRef(null); + + const preventMultipleClicks = (ms: number) => { + if (timeoutRef.current) { + window.clearTimeout(timeoutRef.current); + } + + isDisabledRef.current = true; + timeoutRef.current = window.setTimeout(() => { + isDisabledRef.current = false; + timeoutRef.current = null; + }, ms); + }; + const loginWithApple = () => { + if (isDisabledRef.current) return; + preventMultipleClicks(2000); window.location.href = `${APPLE_AUTHORIZE_URL}&state=${window.location.origin}`; };