Skip to content

Commit

Permalink
fix: remove very stupid turnstile thing
Browse files Browse the repository at this point in the history
  • Loading branch information
IncognitoTGT committed Nov 7, 2024
1 parent 87ee084 commit acff8dd
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 25 deletions.
7 changes: 0 additions & 7 deletions .config/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,6 @@
"TurnstileConfig": {
"additionalProperties": false,
"properties": {
"hosts": {
"description": "The hosts to enable Turnstile on",
"items": {
"type": "string"
},
"type": "array"
},
"secret": {
"description": "The Turnstile secret key, used by the backend",
"type": "string"
Expand Down
8 changes: 1 addition & 7 deletions src/components/turnstile.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { getConfig } from "@/lib/config";
import { Turnstile as BaseTurnstile } from "@marsidev/react-turnstile";
import { headers } from "next/headers";
export default async function Turnstile() {
const config = getConfig();
const headersList = await headers();
const host = headersList.get("x-forwarded-host") || headersList.get("host");
if (
config?.auth.turnstile?.siteKey &&
(!config.auth.turnstile.hosts || config.auth.turnstile.hosts.includes(host as string))
) {
if (config?.auth.turnstile?.siteKey) {
return <BaseTurnstile siteKey={config.auth.turnstile.siteKey} />;
}
return null;
Expand Down
7 changes: 0 additions & 7 deletions src/lib/turnstile.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import { headers } from "next/headers";
import { getConfig } from "./config";

export default async function turnstileCheck(data: FormData) {
const config = getConfig();
if (!config.auth.turnstile) return true;
const headersList = await headers();
if (
config.auth.turnstile.hosts &&
!config.auth.turnstile.hosts?.includes(headersList.get("x-forwarded-host") || headersList.get("host") || "")
)
return true;
const key = data.get("cf-turnstile-response")?.toString();
const result = await fetch("https://challenges.cloudflare.com/turnstile/v0/siteverify", {
body: JSON.stringify({
Expand Down
4 changes: 0 additions & 4 deletions src/types/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,4 @@ export interface TurnstileConfig {
* The Turnstile site key, used by the frontend
*/
siteKey: string;
/**
* The hosts to enable Turnstile on
*/
hosts?: string[];
}

0 comments on commit acff8dd

Please sign in to comment.