2023-03-04 02:09:05 +01:00
|
|
|
const express = require('express');
|
|
|
|
const router = express.Router();
|
|
|
|
const handler = require('express-async-handler');
|
2023-03-04 06:00:53 +01:00
|
|
|
const content = require('../helpers/content');
|
2023-03-04 02:09:05 +01:00
|
|
|
|
2023-04-17 02:37:07 +02:00
|
|
|
const crypto = require('crypto');
|
|
|
|
|
2023-03-04 02:09:05 +01:00
|
|
|
async function index(req, res) {
|
2023-04-17 02:37:07 +02:00
|
|
|
|
|
|
|
if (!req.session.captcha) {
|
|
|
|
req.session.captcha = crypto.randomBytes(8).toString('base64').substring(0, 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
req.session.captcha_input = crypto.randomBytes(8).toString('base64').substring(0,10);
|
|
|
|
if (!req.session.csrf)
|
|
|
|
req.session.csrf = crypto.randomBytes(10).toString('base64');
|
|
|
|
|
2023-03-04 06:00:53 +01:00
|
|
|
res.render('main', {
|
|
|
|
maxlen: process.env.MAXLEN,
|
2023-04-17 02:37:07 +02:00
|
|
|
submitted: content.submitted(),
|
|
|
|
req,
|
|
|
|
crypto
|
2023-03-04 06:00:53 +01:00
|
|
|
});
|
2023-04-17 02:37:07 +02:00
|
|
|
|
2023-03-04 02:09:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
router.get('/', handler(index));
|
|
|
|
|
|
|
|
module.exports = router;
|