bigly-chat/form/captcha.js
2024-10-28 04:54:58 -04:00

26 lines
No EOL
579 B
JavaScript

import Route from "../route.js";
import initDb from "../db.js";
let db = await initDb();
let main = new Route([], async function (req, res, input) {
let body = { ...req.cookies, ...req.body };
let { captcha, challenger } = body;
let match = await db.all('SELECT * FROM captcha WHERE key = ? AND solution = ?', [
captcha,
challenger
]);
await db.all('DELETE FROM captcha WHERE key = ? AND solution = ?', [
captcha,
challenger
]);
return {
captchaMatch: (match.length > 0)
};
});
export default main;