captcha: add captcha to contact page (fixes #482)
This commit is contained in:
parent
004adcd5fe
commit
4cecdef35a
4 changed files with 39 additions and 37 deletions
14
files/helpers/captcha.py
Normal file
14
files/helpers/captcha.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from typing import Final
|
||||
import requests
|
||||
|
||||
HCAPTCHA_URL: Final[str] = "https://hcaptcha.com/siteverify"
|
||||
|
||||
def validate_captcha(secret:str, sitekey: str, token: str):
|
||||
if not sitekey: return True
|
||||
if not token: return False
|
||||
data = {"secret": secret,
|
||||
"response": token,
|
||||
"sitekey": sitekey
|
||||
}
|
||||
req = requests.post(HCAPTCHA_URL, data=data, timeout=5)
|
||||
return bool(req.json()["success"])
|
Loading…
Add table
Add a link
Reference in a new issue