Load Turnstile site key at runtime
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 54s

This commit is contained in:
Cauê Faleiros
2026-07-28 13:03:51 -03:00
parent 20dde11ff0
commit ed3a3f0571
9 changed files with 77 additions and 25 deletions

View File

@@ -1,6 +1,6 @@
const express = require('express');
const { login } = require('../auth');
const { TURNSTILE_SECRET } = require('../config');
const { TURNSTILE_SECRET, TURNSTILE_SITE_KEY } = require('../config');
const router = express.Router();
const TURNSTILE_VERIFY_URL = 'https://challenges.cloudflare.com/turnstile/v0/siteverify';
@@ -34,6 +34,13 @@ const verifyCaptcha = async (captchaToken, remoteIp) => {
}
};
router.get('/login/config', (req, res) => {
res.json({
captchaRequired: Boolean(TURNSTILE_SECRET),
turnstileSiteKey: TURNSTILE_SITE_KEY
});
});
router.post('/login', async (req, res, next) => {
const { email, password, captchaToken } = req.body;