Add ability to change message type in middleware util

This commit is contained in:
Berkeley Martinez
2015-12-29 11:43:06 -08:00
parent 8c3e14cd8e
commit d745e3a254
2 changed files with 6 additions and 4 deletions

View File

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