akf-forum/routes/post/admin.js

23 lines
613 B
JavaScript
Raw Normal View History

2022-03-13 16:16:46 +03:00
const { User } = require("../../classes/index");
const error = require("../../errors/error.js");
module.exports = (req, res) => {
if (!req.session.loggedin) return res.redirect('/login');
const user = new User().getId(req.session.userid)
if (!user.admin) return error(res, 404, "You have not got permissions for view to this page.");
const user2 = new User().getId(req.body.userid)
if (!user2) return error(res, 404, "We have not got this user in all of forum. Vesselam.");
else {
user2.admin = true;
user2.write()
}
res.render("admin", { user, user2 })
2022-03-13 16:16:46 +03:00
}