So my web application requires authentication, and I have a signup page where if the person tries to sign up with an email that is already in the database, I want to show them an error message. I'm trying to do this using this code on the html side:
<% if (message.length > 0) { %>
<div class="alert alert-danger"><%= message %></div>
<% } %>
And doing this in my routes:
router.get('/signup', function(req, res) {
res.render('/signup', { message: req.flash('signupMessage') });
});
I've tried setting up the config with something along the lines of:
app.configure(function() {
app.use(express.session({ secret : 'keyboard cat' }));
});
But this gives me a TypeError:
12:11:38 web.1 | app.configure(function() {
12:11:38 web.1 | ^
12:11:38 web.1 | TypeError: Object function (req, res, next) {
I'm really confused, because I know I need sessions to be working for flash to work, but sessions don't seem to be working for me. I've also tried using only sessions and no flash, by using req.session.messages, but since I don't have sessions working this obviously did not work.
Any insights?
I'm using Express 4.0.0
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…