File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
apps/dashboard/src/app/api/testnet-faucet/claim Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 1+ import { COOKIE_ACTIVE_ACCOUNT , COOKIE_PREFIX_TOKEN } from "@/constants/cookie" ;
12import { startOfToday } from "date-fns" ;
23import { cacheGet , cacheSet } from "lib/redis" ;
34import { type NextRequest , NextResponse } from "next/server" ;
4- import { ZERO_ADDRESS } from "thirdweb" ;
5+ import { ZERO_ADDRESS , getAddress } from "thirdweb" ;
56import { getFaucetClaimAmount } from "./claim-amount" ;
67
78const THIRDWEB_ENGINE_URL = process . env . THIRDWEB_ENGINE_URL ;
@@ -19,6 +20,20 @@ interface RequestTestnetFundsPayload {
1920
2021// Note: This handler cannot use "edge" runtime because of Redis usage.
2122export const POST = async ( req : NextRequest ) => {
23+ // Make sure user's connected to the site
24+ const activeAccount = req . cookies . get ( COOKIE_ACTIVE_ACCOUNT ) ?. value ;
25+ const authCookie = activeAccount
26+ ? req . cookies . get ( COOKIE_PREFIX_TOKEN + getAddress ( activeAccount ) )
27+ : null ;
28+ if ( ! authCookie ) {
29+ return NextResponse . json (
30+ {
31+ error : "No wallet connected" ,
32+ } ,
33+ { status : 400 } ,
34+ ) ;
35+ }
36+
2237 const requestBody = ( await req . json ( ) ) as RequestTestnetFundsPayload ;
2338 const { chainId, toAddress, turnstileToken } = requestBody ;
2439 if ( Number . isNaN ( chainId ) ) {
You can’t perform that action at this time.
0 commit comments