fix(server/flash): Api to match documentation
This fixes duplication issues and normalize our use with everyone else
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
export function ifNoUserRedirectTo(url, message, type = 'danger') {
|
||||
import dedent from 'dedent';
|
||||
|
||||
export function ifNoUserRedirectTo(url, message, type = 'errors') {
|
||||
return function(req, res, next) {
|
||||
const { path } = req;
|
||||
if (req.user) {
|
||||
return next();
|
||||
}
|
||||
|
||||
req.flash(type, {
|
||||
msg: message || `You must be signed in to access ${path}`
|
||||
});
|
||||
req.flash(type, message || `You must be signed in to access ${path}`);
|
||||
|
||||
return res.redirect(url);
|
||||
};
|
||||
@@ -35,10 +35,13 @@ export function ifNotVerifiedRedirectToSettings(req, res, next) {
|
||||
return next();
|
||||
}
|
||||
if (!user.emailVerified) {
|
||||
req.flash('danger', {
|
||||
msg: 'We do not have your verified email address on record, '
|
||||
+ 'please add it in the settings to continue with your request.'
|
||||
});
|
||||
req.flash(
|
||||
'danger',
|
||||
dedent`
|
||||
We do not have your verified email address on record,
|
||||
please add it in the settings to continue with your request.
|
||||
`
|
||||
);
|
||||
return res.redirect('/settings');
|
||||
}
|
||||
return next();
|
||||
|
Reference in New Issue
Block a user