akf-forum/middlewares/user.js

7 lines
No EOL
246 B
JavaScript

const { UserModel } = require("../models");
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);
next();
}