File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414load_dotenv ()
1515import os
1616
17+
1718# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
1819BASE_DIR = os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))
1920
2324RECAPTCHA_SITE_KEY = os .getenv ("RECAPTCHA_SITE_KEY" )
2425RECAPTCHA_SECRET_KEY = os .getenv ("RECAPTCHA_SECRET_KEY" )
2526
27+
2628RECAPTCHA_SITE_KEY_v3 = os .getenv ("RECAPTCHA_SITE_KEY_v3" )
2729RECAPTCHA_SECRET_KEY_v3 = os .getenv ("RECAPTCHA_SECRET_KEY_v3" )
2830
Original file line number Diff line number Diff line change 11from django .conf import settings
22from django .shortcuts import render
3+ from forums .settings import RECAPTCHA_SITE_KEY_v3
34
45class FilterCaptchaGateMiddleware (object ):
56 """
@@ -15,8 +16,9 @@ def __init__(self, get_response=None):
1516 self .get_response = get_response
1617
1718 def __call__ (self , request ):
19+
1820 path = request .path
19-
21+
2022 # Only apply to filter endpoints
2123 if path .startswith ('/filter/' ):
2224
@@ -39,7 +41,7 @@ def __call__(self, request):
3941 if needs_verification :
4042 context = {
4143 'next_url' : request .get_full_path (),
42- 'site_key' : settings . RECAPTCHA_SITE_KEY_v3
44+ 'site_key' : RECAPTCHA_SITE_KEY_v3
4345 }
4446 return render (request , 'website/templates/filter_verify.html' ,context )
4547
Original file line number Diff line number Diff line change 2323from forums .views import user_logout
2424from website .permissions import is_administrator , is_forumsadmin
2525
26+ from forums .settings import RECAPTCHA_SECRET_KEY_v3
2627User = get_user_model ()
2728
2829HOME_CACHE_TIMEOUT = 3600
@@ -1102,7 +1103,7 @@ def verify_filter_access(request):
11021103 return HttpResponseForbidden ("Missing captcha token" )
11031104
11041105 try :
1105- data = {'secret' : settings . RECAPTCHA_SECRET_KEY_v3 , 'response' : token }
1106+ data = {'secret' : RECAPTCHA_SECRET_KEY_v3 , 'response' : token }
11061107 resp = requests .post ('https://www.google.com/recaptcha/api/siteverify' ,
11071108 data , timeout = 5 )
11081109 result = resp .json ()
You can’t perform that action at this time.
0 commit comments