mirror of
https://github.com/Mail-0/Zero.git
synced 2026-06-28 06:46:15 +00:00
removed turnstile
This commit is contained in:
@@ -3,11 +3,11 @@ NEXT_PUBLIC_APP_URL=http://localhost:3000
|
||||
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mail0"
|
||||
|
||||
# Change this to a random string, use `openssl rand -hex 32` to generate a 32 character string
|
||||
BETTER_AUTH_SECRET=my-better-auth-secret
|
||||
BETTER_AUTH_SECRET=my-better-auth-secret
|
||||
BETTER_AUTH_URL=http://localhost:3000
|
||||
BETTER_AUTH_TRUSTED_ORIGINS=http://localhost:3000
|
||||
|
||||
# Change to your project's client ID and secret, these work with localhost:3000 and localhost:3001
|
||||
# Change to your project's client ID and secret, these work with localhost:3000 and localhost:3001
|
||||
GOOGLE_CLIENT_ID=
|
||||
GOOGLE_CLIENT_SECRET=
|
||||
GOOGLE_REDIRECT_URI=http://localhost:3000/api/v1/mail/auth/google/callback
|
||||
@@ -22,5 +22,4 @@ REDIS_URL="http://localhost:8079"
|
||||
REDIS_TOKEN="upstash-local-token"
|
||||
|
||||
# Resend API Key
|
||||
RESEND_API_KEY=
|
||||
NEXT_PUBLIC_TURNSTILE_SITE_KEY=
|
||||
RESEND_API_KEY=
|
||||
@@ -15,8 +15,6 @@ const ratelimit = new Ratelimit({
|
||||
analytics: true,
|
||||
prefix: "ratelimit:early-access",
|
||||
});
|
||||
const verifyEndpoint = 'https://challenges.cloudflare.com/turnstile/v0/siteverify'
|
||||
const secret = process.env.TURNSTILE_SECRET_KEY!
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
try {
|
||||
@@ -41,28 +39,13 @@ export async function POST(req: NextRequest) {
|
||||
const body = await req.json();
|
||||
console.log("Request body:", body);
|
||||
|
||||
const { email, token } = body;
|
||||
const { email } = body;
|
||||
|
||||
if (!email) {
|
||||
console.log("Email missing from request");
|
||||
return NextResponse.json({ error: "Email is required" }, { status: 400 });
|
||||
}
|
||||
|
||||
const verifyRequest = await fetch(verifyEndpoint, {
|
||||
method: 'POST',
|
||||
body: `secret=${encodeURIComponent(secret)}&response=${encodeURIComponent(token)}&remoteip=${ip}`,
|
||||
headers: {
|
||||
'content-type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
})
|
||||
|
||||
const verifyResponse = await verifyRequest.json()
|
||||
|
||||
if (!verifyResponse.success) {
|
||||
console.warn("Turnstile verification failed:", verifyResponse.error)
|
||||
return NextResponse.json({ error: "Invalid turnstile verification" }, { status: 400 });
|
||||
}
|
||||
|
||||
const nowDate = new Date();
|
||||
|
||||
try {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import { Form, FormControl, FormField, FormItem } from "../ui/form";
|
||||
import { AnimatedNumber } from "../ui/animated-number";
|
||||
import { Turnstile } from "@marsidev/react-turnstile";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { Card, CardContent } from "../ui/card";
|
||||
import { useState, useEffect } from "react";
|
||||
@@ -25,7 +24,6 @@ export default function Hero() {
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [showSuccess, setShowSuccess] = useState(false);
|
||||
const [signupCount, setSignupCount] = useState<number>(0);
|
||||
const [token, setToken] = useState<string>();
|
||||
|
||||
const form = useForm<z.infer<typeof betaSignupSchema>>({
|
||||
resolver: zodResolver(betaSignupSchema),
|
||||
@@ -48,16 +46,12 @@ export default function Hero() {
|
||||
}, []);
|
||||
|
||||
const onSubmit = async (values: z.infer<typeof betaSignupSchema>) => {
|
||||
if (!token) {
|
||||
return toast.error("Please complete the captcha before submitting");
|
||||
}
|
||||
setIsSubmitting(true);
|
||||
try {
|
||||
console.log("Starting form submission with email:", values.email);
|
||||
|
||||
const response = await axios.post("/api/auth/early-access", {
|
||||
email: values.email,
|
||||
token,
|
||||
});
|
||||
|
||||
console.log("Response data:", response.data);
|
||||
@@ -109,7 +103,7 @@ export default function Hero() {
|
||||
We'll let you know when we're ready to revolutionize your email experience.
|
||||
</p>
|
||||
</div>
|
||||
) : process.env.NODE_ENV === "development" ? (
|
||||
) : process.env.NODE_ENV !== "development" ? (
|
||||
<div className="flex items-center justify-center gap-4">
|
||||
<Button
|
||||
variant="outline"
|
||||
@@ -162,14 +156,7 @@ export default function Hero() {
|
||||
</form>
|
||||
</Form>
|
||||
)}
|
||||
{process.env.NODE_ENV !== "development" && !showSuccess ? (
|
||||
<span className="pt-4">
|
||||
<Turnstile
|
||||
siteKey={process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY!}
|
||||
onSuccess={setToken}
|
||||
/>
|
||||
</span>
|
||||
) : null}
|
||||
|
||||
{signupCount !== null && (
|
||||
<div className="text-shinyGray mt-4 text-center text-sm">
|
||||
<span className="font-semibold text-white">
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@hookform/resolvers": "4.1.2",
|
||||
"@marsidev/react-turnstile": "1.1.0",
|
||||
"@radix-ui/react-avatar": "1.1.3",
|
||||
"@radix-ui/react-collapsible": "1.1.3",
|
||||
"@radix-ui/react-dialog": "1.1.6",
|
||||
|
||||
14
pnpm-lock.yaml
generated
14
pnpm-lock.yaml
generated
@@ -42,9 +42,6 @@ importers:
|
||||
'@hookform/resolvers':
|
||||
specifier: 4.1.2
|
||||
version: 4.1.2(react-hook-form@7.54.2(react@19.0.0))
|
||||
'@marsidev/react-turnstile':
|
||||
specifier: 1.1.0
|
||||
version: 1.1.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
|
||||
'@radix-ui/react-avatar':
|
||||
specifier: 1.1.3
|
||||
version: 1.1.3(@types/react-dom@19.0.4(@types/react@19.0.10))(@types/react@19.0.10)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
|
||||
@@ -884,12 +881,6 @@ packages:
|
||||
'@levischuck/tiny-cbor@0.2.11':
|
||||
resolution: {integrity: sha512-llBRm4dT4Z89aRsm6u2oEZ8tfwL/2l6BwpZ7JcyieouniDECM5AqNgr/y08zalEIvW3RSK4upYyybDcmjXqAow==}
|
||||
|
||||
'@marsidev/react-turnstile@1.1.0':
|
||||
resolution: {integrity: sha512-X7bP9ZYutDd+E+klPYF+/BJHqEyyVkN4KKmZcNRr84zs3DcMoftlMAuoKqNSnqg0HE7NQ1844+TLFSJoztCdSA==}
|
||||
peerDependencies:
|
||||
react: ^17.0.2 || ^18.0.0 || ^19.0
|
||||
react-dom: ^17.0.2 || ^18.0.0 || ^19.0
|
||||
|
||||
'@next/env@15.2.0':
|
||||
resolution: {integrity: sha512-eMgJu1RBXxxqqnuRJQh5RozhskoNUDHBFybvi+Z+yK9qzKeG7dadhv/Vp1YooSZmCnegf7JxWuapV77necLZNA==}
|
||||
|
||||
@@ -5384,11 +5375,6 @@ snapshots:
|
||||
|
||||
'@levischuck/tiny-cbor@0.2.11': {}
|
||||
|
||||
'@marsidev/react-turnstile@1.1.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0)':
|
||||
dependencies:
|
||||
react: 19.0.0
|
||||
react-dom: 19.0.0(react@19.0.0)
|
||||
|
||||
'@next/env@15.2.0': {}
|
||||
|
||||
'@next/eslint-plugin-next@15.2.0':
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
"GITHUB_CLIENT_SECRET",
|
||||
"REDIS_URL",
|
||||
"REDIS_TOKEN",
|
||||
"RESEND_API_KEY",
|
||||
"NEXT_PUBLIC_TURNSTILE_SITE_KEY",
|
||||
"TURNSTILE_SECRET_KEY"
|
||||
"RESEND_API_KEY"
|
||||
],
|
||||
"dependsOn": ["^build"],
|
||||
"inputs": ["$TURBO_DEFAULT$", ".env*"],
|
||||
|
||||
Reference in New Issue
Block a user