-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added captcha to login and register page
- Loading branch information
Showing
5 changed files
with
79 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use server' | ||
import { HTTP_STATUS } from "../constants"; | ||
|
||
export async function captchaVerify (token:string) { | ||
const SECRET_KEY = "0x4AAAAAAAbu8XnHHmSbg9kLI3T3HziPSuI" | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
let formData = new FormData(); | ||
formData.append('secret', SECRET_KEY); | ||
formData.append('response', token); | ||
|
||
const url = 'https://challenges.cloudflare.com/turnstile/v0/siteverify'; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
const result = await fetch(url, { | ||
body: formData, | ||
method: 'POST', | ||
}); | ||
|
||
const challengeSucceeded = (await result.json()).success; | ||
|
||
if (!challengeSucceeded) { | ||
return HTTP_STATUS.FORBIDDEN | ||
} | ||
else{ | ||
return HTTP_STATUS.OK | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Refer 1