blob: 7bcfb34e1385e199df6d47f52e4c9320dfcd4f12 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
module.exports = (req, res, next) => {
req.setOldForm = (errors) => {
let prettyErrors = {};
Object.keys(errors.errors).forEach(err => {
prettyErrors[err] = errors.errors[err].message;
});
req.session.oldForm = {
errors: prettyErrors,
values: req.body
};
};
if (!req.session.oldForm) req.session.oldForm = {
errors: null,
values: null
};
res.locals.oldForm = req.session.oldForm;
delete req.session.oldForm;
next();
};
|