Gregniuki commited on
Commit
40e39c9
1 Parent(s): 89ee564

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -220,6 +220,22 @@ async def registration_successful(request: Request, db: Session = Depends(get_db
220
  response = RedirectResponse(url="/protected")
221
  response.set_cookie(key="access_token", value=f"Bearer {access_token}", httponly=True)
222
  return response
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
 
224
  @app.get("/register", response_class=HTMLResponse)
225
  async def register_get(request: Request):
 
220
  response = RedirectResponse(url="/protected")
221
  response.set_cookie(key="access_token", value=f"Bearer {access_token}", httponly=True)
222
  return response
223
+
224
+ async def verify_recaptcha(recaptcha_token: str) -> bool:
225
+ recaptcha_secret = '6LeSJgwpAAAAAJrLrvlQYhRsOjf2wKXee_Jc4Z-k' # Replace with your reCAPTCHA secret key
226
+ recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify'
227
+ recaptcha_data = {
228
+ 'secret': recaptcha_secret,
229
+ 'response': recaptcha_token
230
+ }
231
+
232
+ async with httpx.AsyncClient() as client:
233
+ recaptcha_response = await client.post(recaptcha_url, data=recaptcha_data)
234
+
235
+ recaptcha_result = recaptcha_response.json()
236
+ print(recaptcha_result) # or use proper logging
237
+
238
+ return recaptcha_result.get('success', False)
239
 
240
  @app.get("/register", response_class=HTMLResponse)
241
  async def register_get(request: Request):