akf-forum/middlewares/user.js

7 lines
246 B
JavaScript
Raw Normal View History

const { UserModel } = require("../models");
2022-04-06 21:14:46 +03:00
module.exports = async (req, res, next) => {
res.error = (type, error) => res.status(type).render("error", { type, error });
req.user = await UserModel.get(req.session.userid);
2022-04-06 21:14:46 +03:00
next();
}