akf-forum/routes/post/createThread.js
2022-02-26 21:12:54 +03:00

12 lines
No EOL
361 B
JavaScript

const { User, Thread } = require("../../classes/index");
module.exports = (req, res) => {
if (!req.session.loggedin) return res.redirect('/login');
const info = req.body;
const thread = new Thread(info.title, info.content, new User().getId(req.session.userid)).takeId();
thread.write()
res.redirect('/threads/' + thread.id);
}