- Restructure: move backend from new_project/ to backend/ - Add full React/TypeScript frontend (37 pages, 17 services, 16 type defs, 11 query hooks) - Add docs/ with SRS specs, user stories, and workflow documentation - Update .gitignore for new directory layout Workflows implemented: WF1 User Signup, WF2 Placement Test, WF3 Exam Configuration, WF4 General English Exam, WF5 Course Generation, WF6 Entity Student Onboarding, AI Course Generation, Adaptive Learning Engine UI, White-Label Branding, Score Release Made-with: Cursor
34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
import requests
|
|
from odoo import api, SUPERUSER_ID
|
|
|
|
|
|
class CaptchaService:
|
|
|
|
def __init__(self, env):
|
|
self.env = env
|
|
|
|
def verify(self, token):
|
|
"""Verify CAPTCHA token against configured provider."""
|
|
ICP = self.env['ir.config_parameter'].sudo()
|
|
secret_key = ICP.get_param('encoach.captcha_secret_key', '')
|
|
provider = ICP.get_param('encoach.captcha_provider', 'recaptcha')
|
|
|
|
if provider == 'recaptcha':
|
|
url = 'https://www.google.com/recaptcha/api/siteverify'
|
|
elif provider == 'hcaptcha':
|
|
url = 'https://hcaptcha.com/siteverify'
|
|
elif provider == 'turnstile':
|
|
url = 'https://challenges.cloudflare.com/turnstile/v0/siteverify'
|
|
else:
|
|
return False
|
|
|
|
try:
|
|
resp = requests.post(url, data={
|
|
'secret': secret_key,
|
|
'response': token,
|
|
}, timeout=10)
|
|
result = resp.json()
|
|
return result.get('success', False)
|
|
except Exception:
|
|
return False
|