Skip to content

Commit

Permalink
Merge pull request #37 from gnosischain/feature/improve-captcha
Browse files Browse the repository at this point in the history
Feature/improve captcha
  • Loading branch information
giacomognosis authored Apr 10, 2024
2 parents d299ec6 + 2bc83da commit 3b016fa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ FAUCET_RPC_URL=https://rpc.chiadochain.net
FAUCET_CHAIN_ID=10200
FAUCET_DATABASE_URI=sqlite://
CAPTCHA_VERIFY_ENDPOINT=https://api.hcaptcha.com/siteverify
CAPTCHA_SECRET_KEY=0x0000000000000000000000000000000000000000
CAPTCHA_SECRET_KEY=0x0000000000000000000000000000000000000000
CAPTCHA_SITE_KEY=xxxxx-xxxxx-xxxxx-xxxxx
6 changes: 6 additions & 0 deletions api/api/services/captcha.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import requests
import logging


logging.basicConfig(level=logging.INFO)


def captcha_verify(client_response, catpcha_api_url, secret_key, remote_ip, site_key):
Expand All @@ -9,6 +13,8 @@ def captcha_verify(client_response, catpcha_api_url, secret_key, remote_ip, site
'sitekey': site_key
})

logging.info('Captcha verify response: %s' % request.json())

if request.status_code != 200:
return False
return request.json()['success'] == True
10 changes: 10 additions & 0 deletions api/scripts/local_run_api.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -euo pipefail


echo "==> $(date +%H:%M:%S) ==> Migrating DB models... "
FLASK_APP=api python -m flask db upgrade

echo "==> $(date +%H:%M:%S) ==> Running Gunicorn... "
exec gunicorn --bind localhost:8000 "api:create_app()"

0 comments on commit 3b016fa

Please sign in to comment.