Created
September 12, 2019 02:27
-
-
Save mpragnarok/2ec5fed0167a61c87d65d7f974c96909 to your computer and use it in GitHub Desktop.
message setting in the user router
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src\routers\user.js | |
// show login page | |
router.get('/login', async (req, res) => { | |
try { | |
res.render('login', { message: req.flash('error') }) | |
} catch (e) { | |
res.status(500).send() | |
} | |
}) | |
// login authentication | |
router.post('/login', async (req, res, next) => { | |
try { | |
passport.authenticate('local', { | |
successRedirect: '/', | |
failureRedirect: '/users/login', | |
badRequestMessage: 'The email does not match any account', // change "missing credentials" message | |
failureFlash: true | |
})(req, res, next) | |
} catch (e) { | |
res.status(400).send() | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment