I am facing an issue with this code
router.get("/timecard", ensureAuthenticated, async(req, res)=>{
users = await User.find();
console.log(req.user.cwlEmployee);
if(req.user.cwlEmployee !== true){
req.flash('error_msg', 'You do not have access to that page, sorry.');
res.render('dashboard', {
name: req.user.name
})
}else{
res.render('ep/timecard', {
name: req.user.name,
users: users
});
}});
Although the console.log() outputs true, the if statement below is behaving as if req.user.cwlEmployee is false.
I am puzzled by this behavior. This code snippet has always worked fine in other parts of my application.