req.flash is not a function
See original GitHub issueWhen I configure my login route as following:
router.post('/login', passport.authenticate('local', {
successRedirect: '/user/logout',
failureRedirect: '/user/login?wrong',
failureFlash: true
}));
I got a req.flash is not a function error. And indeed, req.flash is undefined.
PS: don’t take care about URL, it’s just for testing purposes. 😉
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
How to resolve req.flash is not a function in node js
req.flash is not a function. I have installed connection-flash npm and session and express-session but instead of that it is throwing an ...
Read more >req.flash is not a function" using passport with nodejs ... - Reddit
javascript - "TypeError: req. flash is not a function" using passport with nodejs, username and password auth .. any ideas? : r/node.
Read more >Confusing TypeError req.flash is not a function #8 - GitHub
Hi Jared, i've been implementing a REST API and need to implement a login route. I've read the docs and you example here,...
Read more >[Solved]-Stuck with req.flash is not a function error-node.js
this error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not...
Read more >Typeerror: Req.Flash Is Not A Function' With App.Use(Flash())
I've read the docs and you example here, but I am receiving an error that I can't identify Confusing TypeError req.flash is not...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I adapted the above to Koa 2:
I managed to separate flash messages into cookies and exposing under
ctx.flash. I used the example boilerplate from my previous post. Because passport.js targetingctx.session.flashby default, you have to write your own authentication redirects in your router:This stores a json cookie in a similar object what passport creating by default. The cookies is always deleted after 10 seconds or on the next request. 10 second is defined in the linked implementation, meaning if a request takes longer, than the user can miss the flash, but you can define longer period.