From e68d1047aaaa09b19f7ff9d9fa1884ae4dd0fc26 Mon Sep 17 00:00:00 2001 From: Wingysam Date: Fri, 23 Nov 2018 12:41:08 -0500 Subject: [PATCH] Better flash --- middlewares/locals.js | 2 -- views/includes/messages.pug | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/middlewares/locals.js b/middlewares/locals.js index dcf8de0..6abd613 100644 --- a/middlewares/locals.js +++ b/middlewares/locals.js @@ -1,7 +1,5 @@ const config = require('../config'); module.exports = (req, res, next) => { - res.locals.successes = req.flash('success'); - res.locals.errors = req.flash('error'); res.locals.config = config; res.locals.req = req; next(); diff --git a/views/includes/messages.pug b/views/includes/messages.pug index 661d8c1..8a25684 100644 --- a/views/includes/messages.pug +++ b/views/includes/messages.pug @@ -1,6 +1,9 @@ +- successes = req.flash('success'); +- errors = req.flash('error'); + if successes each success in successes - p.has-text-success= success + p.has-text-success= (success.toString().startsWith('[object ') ? JSON.stringify(success) : success.toString()) if errors each error in errors - p.has-text-danger= error \ No newline at end of file + p.has-text-danger= (error.toString().startsWith('[object ') ? JSON.stringify(error) : error.toString()) \ No newline at end of file