Questions tagged [connect-flash]

Express middleware for storing messages in the session. Connect-flash was part of Express until Express 3. connect-flash

107 questions
2
votes
3 answers

How to use connect-flash with ejs in express 4.x

I have a project that I need to use connect-flash, I am using view engine as ejs. Even I configure everything fine, in my opinion, connect-flash doesn't work. Could anybody please help me abput that? Here how did I define the session, connect-flash…
Mert
  • 41
  • 1
  • 4
2
votes
1 answer

Express connect-flash displays only after refresh not on the same page.how to solve this?

below is register route router.post("/register", function(req, res){ var newUser= new User({username:req.body.username}); User.register(newUser,req.body.password, function(error,user){ if(error){ req.flash("error",…
Harsh kumar
  • 55
  • 10
2
votes
0 answers

how to include variable in connect-flash message to create dynamic link

I am struggling to create a dynamic link (include variable :id) into error flash message. The link should redirect to existing entry. JS req.flash('errors', 'Name already in use!'+'Edit existing player…
2
votes
4 answers

How do I get connect-flash to return multiple messages, or a single message with newline characters?

I'm building an app using nodejs. I created a form, and I'm working on back-end validation of user input. Basically, I have a var, "messages", and each time I encounter an input error, I append the error to messages. var messages…
Asool
  • 13,031
  • 7
  • 35
  • 49
2
votes
2 answers

How to call flash on the client-side?

CODE: login.ejs header.ejs
<% if (success_msg != false){ %> <%=…
Coder1000
  • 4,071
  • 9
  • 35
  • 84
2
votes
1 answer

Unable to show flash message from Passport.js

I'm having problem with sending a flash if authentication fails. Except that everything is OK. When I'm copying example (https://github.com/jaredhanson/connect-flash) to my app flash messages are working fine... Here is my…
Jarosław Rewers
  • 1,059
  • 3
  • 14
  • 23
2
votes
1 answer

What's the best way to handle Node.js flash messages?

I am a beginner with Node.js and i absolutely love it. I wonder how can i handle flash message the best and easiest way. I used connect-flash package in my site. Does it have better ones? I always put my flash messages in my render function like…
Mike Boutin
  • 5,297
  • 12
  • 38
  • 65
2
votes
1 answer

Access flash messages from Jade in Express 4

I am currently learning NodeJS using the Express framework. For some reason, there's not alot of guides for Express 4, but alot for Express 3. I am trying to pass errors from a "register" function back to the Jade template using…
Sven
  • 5,155
  • 29
  • 53
1
vote
1 answer

Why are messages not appearing when using connect-flash with res.locals in express.js and ejs templating?

here are some of the relevant code snippets. connect-flash is able to show messages on test1 and test2. the problem is that no messages is showing for test 3: user registration when all three tests are redirected to the same 'testing'…
aidwiz
  • 11
  • 3
1
vote
0 answers

How to refresh the page without it reloading as a new one?

I am currently trying to use connect-flash to send flash messages to the same page req.flash('error_login', 'Incorrect Username/Password'); res.redirect(req.get('referer')); In doing this I effectively reload the page so that the flash message…
1
vote
0 answers

connect-flash shows [ ] instead of a message (express)

... newArticle.save((err,newArticle)=>{ if(err){ req.flash('error','Sorry , an error has occured. Thamk you try again later') //when i use console.log(req.flash('error')) it shows normally in the terminal …
1
vote
0 answers

Passport.js authenticate failureRedirect with parameters

Working on Passport.js authentication and want to display messages to client when login is not successful. My current logic: app.route('/login').post(passport.authenticate('local', { failureRedirect: '/' }), (req, res) => { …
enszrlu
  • 31
  • 2
1
vote
0 answers

connect-flash is working correctly but not displaying messages

i'm new in node and express. i'm trying to make a register page using connect-flash for validation and using ejs template engine . everything is working correct but nothing displayed in my alert box. here is my registerController.js…
1
vote
1 answer

Login middleware throws a "variable is not defined" error in conjunction with Passport.js

I am currently following a Node.js course by Colt Steele on Udemy and I came across an error that I have no idea how to fix. To be more specific, this error occurs whenever I try to log in to my web app with the correct credentials (it works fine…
1
vote
0 answers

How do you access the messages in the done methods of passport without flash / in a react app?

[Update] Question now contains necessary details because of which the author was successful at finding a solution and hence should be reopened for answers. Question in the title. Is there a way to use connect-flash in the back end (express) so that…
SirNoob
  • 569
  • 1
  • 4
  • 18