Skip to content

Commit

Permalink
Merge pull request #36 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 36ea67b + c12eae3 commit d299ec6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions api/api/services/captcha.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import requests


def captcha_verify(client_response, catpcha_api_url, secret_key):
def captcha_verify(client_response, catpcha_api_url, secret_key, remote_ip, site_key):
request = requests.post(catpcha_api_url, data={
'response': client_response,
'secret': secret_key
'secret': secret_key,
'remoteip': remote_ip,
'sitekey': site_key
})

if request.status_code != 200:
Expand Down
4 changes: 3 additions & 1 deletion api/api/services/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ def captcha_validation(self):
# check hcatpcha
catpcha_verified = captcha_verify(
self.request_data.get('captcha'),
current_app.config['CAPTCHA_VERIFY_ENDPOINT'], current_app.config['CAPTCHA_SECRET_KEY']
current_app.config['CAPTCHA_VERIFY_ENDPOINT'], current_app.config['CAPTCHA_SECRET_KEY'],
self.ip_address,
current_app.config['CAPTCHA_SITE_KEY']
)

if not catpcha_verified:
Expand Down
1 change: 1 addition & 0 deletions api/api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@

CAPTCHA_VERIFY_ENDPOINT = os.getenv('CAPTCHA_VERIFY_ENDPOINT')
CAPTCHA_SECRET_KEY = os.getenv('CAPTCHA_SECRET_KEY')
CAPTCHA_SITE_KEY = os.getenv('CAPTCHA_SITE_KEY')
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@hcaptcha/react-hcaptcha": "^1.9.1",
"@hcaptcha/react-hcaptcha": "1.10.1",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^13.0.0",
"@testing-library/user-event": "^13.2.1",
Expand Down

0 comments on commit d299ec6

Please sign in to comment.