I have a standard expressroute for this login. Even if req.body.password is incorrect I get redirected to '/login'
router.post('/student/login', (req, res) => {
if (req.body.password = 'password') {
return res.status(200).redirect('/login')
} else {
return res.status(401).redirect('/landingpage')
}
})
What am I missing here?
Change the = to === in line two as you are assigning a value with just = and are comparing value with ===
router.post('/student/login', (req, res) => { if (req.body.password === 'password') { return res.status(200).redirect('/login') } else { return res.status(401).redirect('/landingpage') } })
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.