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

@ -24,12 +24,14 @@ import {
const sendNonUserToSignIn = ifNoUserRedirectTo(
'/login',
'You must be signed in to commit to a non-profit'
'You must be signed in to commit to a nonprofit.',
'info'
);
const sendNonUserToCommit = ifNoUserRedirectTo(
'/commit',
'You must be signed in to update commit'
'You must be signed in to update commit',
'info'
);
const debug = debugFactory('freecc:commit');

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}`
});