feat(security): add Cloudflare Turnstile CAPTCHA to registration form

- Add Turnstile widget rendering in RegisterPage on step 2
- Implement programmatic widget initialization with callbacks
- Add token validation before form submission
- Update AuthContext and API service to pass turnstileToken
- Add backend verification via Cloudflare API in register controller
- Include client IP in verification request
- Add validation rule for turnstileToken
- Reset widget on registration error
This commit is contained in:
Radosław Gierwiało
2025-12-05 18:20:26 +01:00
parent f3b8156557
commit d8085f828f
6 changed files with 112 additions and 10 deletions

View File

@@ -112,10 +112,10 @@ async function fetchAPI(endpoint, options = {}) {
// Auth API
export const authAPI = {
async register(username, email, password, firstName = null, lastName = null, wsdcId = null) {
async register(username, email, password, firstName = null, lastName = null, wsdcId = null, turnstileToken = null) {
const data = await fetchAPI('/auth/register', {
method: 'POST',
body: JSON.stringify({ username, email, password, firstName, lastName, wsdcId }),
body: JSON.stringify({ username, email, password, firstName, lastName, wsdcId, turnstileToken }),
});
// Save token