Update main.py
Browse files
main.py
CHANGED
@@ -149,14 +149,24 @@ async def register_post(
|
|
149 |
email: str = Form(...),
|
150 |
password: str = Form(...),
|
151 |
confirm_password: str = Form(...),
|
152 |
-
|
153 |
db: Session = Depends(get_db)
|
154 |
):
|
155 |
# Perform reCAPTCHA verification first
|
156 |
project_id = 'login-auth-1699381988574' # Replace with your project ID
|
157 |
recaptcha_key = '6LdMjQcpAAAAAGtbNZkL17ry1scsQjp1HSEhkLNl' # Replace with your site key
|
158 |
recaptcha_action = 'submit' # The action you're expecting
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
|
|
|
|
|
160 |
# Call the create_assessment function to validate the token
|
161 |
# assessment = await create_assessment( project_id, recaptcha_key, token, recaptcha_action )
|
162 |
# loop = asyncio.get_running_loop()
|
|
|
149 |
email: str = Form(...),
|
150 |
password: str = Form(...),
|
151 |
confirm_password: str = Form(...),
|
152 |
+
recaptcha_token: str = Form(...), # Add this line to accept the reCAPTCHA token
|
153 |
db: Session = Depends(get_db)
|
154 |
):
|
155 |
# Perform reCAPTCHA verification first
|
156 |
project_id = 'login-auth-1699381988574' # Replace with your project ID
|
157 |
recaptcha_key = '6LdMjQcpAAAAAGtbNZkL17ry1scsQjp1HSEhkLNl' # Replace with your site key
|
158 |
recaptcha_action = 'submit' # The action you're expecting
|
159 |
+
recaptcha_secret = '6LdMjQcpAAAAAGtbNZkL17ry1scsQjp1HSEhkLNl' # Replace with your reCAPTCHA secret key
|
160 |
+
recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify'
|
161 |
+
recaptcha_data = {
|
162 |
+
'secret': recaptcha_secret,
|
163 |
+
'response': recaptcha_token
|
164 |
+
}
|
165 |
+
recaptcha_response = requests.post(recaptcha_url, data=recaptcha_data)
|
166 |
+
recaptcha_result = recaptcha_response.json()
|
167 |
|
168 |
+
if not recaptcha_result.get('success', False):
|
169 |
+
raise HTTPException(status_code=400, detail="reCAPTCHA validation failed.")
|
170 |
# Call the create_assessment function to validate the token
|
171 |
# assessment = await create_assessment( project_id, recaptcha_key, token, recaptcha_action )
|
172 |
# loop = asyncio.get_running_loop()
|