Add redirect to user page on submit

This commit is contained in:
Berkeley Martinez
2015-10-06 00:13:51 -07:00
parent d1c0276f4e
commit bc6a9c6db2
5 changed files with 79 additions and 12 deletions

View File

@ -1,8 +1,14 @@
export function ifNoUserRedirectTo(url) {
export function ifNoUserRedirectTo(url, message) {
return function(req, res, next) {
const { path } = req;
if (req.user) {
return next();
}
req.flash('errors', {
msg: message || `You must be signed to go to ${path}`
});
return res.redirect(url);
};
}