@@ -4,9 +4,11 @@ import { redirectToCheckout } from "@/actions/billing";
44import { getRawAccountAction } from "@/actions/getAccount" ;
55import { ToggleThemeButton } from "@/components/color-mode-toggle" ;
66import { Spinner } from "@/components/ui/Spinner/Spinner" ;
7+ import { TURNSTILE_SITE_KEY } from "@/constants/env" ;
78import { useThirdwebClient } from "@/constants/thirdweb.client" ;
89import { useDashboardRouter } from "@/lib/DashboardRouter" ;
910import type { Account } from "@3rdweb-sdk/react/hooks/useApi" ;
11+ import { Turnstile } from "@marsidev/react-turnstile" ;
1012import { useTheme } from "next-themes" ;
1113import Link from "next/link" ;
1214import { Suspense , lazy , useEffect , useState } from "react" ;
@@ -216,36 +218,49 @@ function CustomConnectEmbed(props: {
216218} ) {
217219 const { theme } = useTheme ( ) ;
218220 const client = useThirdwebClient ( ) ;
221+ const [ turnstileToken , setTurnstileToken ] = useState ( "" ) ;
219222
220223 return (
221- < ConnectEmbed
222- auth = { {
223- getLoginPayload,
224- doLogin : async ( params ) => {
225- try {
226- await doLogin ( params ) ;
227- props . onLogin ( ) ;
228- } catch ( e ) {
229- console . error ( "Failed to login" , e ) ;
230- throw e ;
231- }
232- } ,
233- doLogout,
234- isLoggedIn : async ( x ) => {
235- const isLoggedInResult = await isLoggedIn ( x ) ;
236- if ( isLoggedInResult ) {
237- props . onLogin ( ) ;
238- }
239- return isLoggedInResult ;
240- } ,
241- } }
242- wallets = { wallets }
243- client = { client }
244- modalSize = "wide"
245- theme = { getSDKTheme ( theme === "light" ? "light" : "dark" ) }
246- className = "shadow-lg"
247- privacyPolicyUrl = "/privacy-policy"
248- termsOfServiceUrl = "/terms"
249- />
224+ < div className = "flex flex-col items-center gap-4" >
225+ < ConnectEmbed
226+ auth = { {
227+ getLoginPayload,
228+ doLogin : async ( params ) => {
229+ try {
230+ await doLogin ( params , turnstileToken ) ;
231+ props . onLogin ( ) ;
232+ } catch ( e ) {
233+ console . error ( "Failed to login" , e ) ;
234+ throw e ;
235+ }
236+ } ,
237+ doLogout,
238+ isLoggedIn : async ( x ) => {
239+ const isLoggedInResult = await isLoggedIn ( x ) ;
240+ if ( isLoggedInResult ) {
241+ props . onLogin ( ) ;
242+ }
243+ return isLoggedInResult ;
244+ } ,
245+ } }
246+ wallets = { wallets }
247+ client = { client }
248+ modalSize = "wide"
249+ theme = { getSDKTheme ( theme === "light" ? "light" : "dark" ) }
250+ className = "shadow-lg"
251+ privacyPolicyUrl = "/privacy-policy"
252+ termsOfServiceUrl = "/terms"
253+ />
254+ < Turnstile
255+ options = { {
256+ // only show if interaction is required
257+ appearance : "interaction-only" ,
258+ // match the theme of the rest of the app
259+ theme : theme === "light" ? "light" : "dark" ,
260+ } }
261+ siteKey = { TURNSTILE_SITE_KEY }
262+ onSuccess = { ( token ) => setTurnstileToken ( token ) }
263+ />
264+ </ div >
250265 ) ;
251266}
0 commit comments