bradtraversy / node_passport_login

Node.js login, registration and access control using Express and Passport
1.74k stars 1.29k forks source link

How to display new model to the protected view #34

Closed csulit closed 5 years ago

csulit commented 5 years ago

Hi, Brad how to make the new model available to protected view?

// Dashboard
router.get('/dashboard', ensureAuthenticated, (req, res) => {
  res.render('dashboard', {
    user: req.user, <-- This can be viewed
    phone: req.phone
  })
});
// Phone view
router.get('/phones', ensureAuthenticated, (req, res) => {
  res.render('phones', {
    phone: req.phone <-- This one not
  })
});
bksubramanyarao commented 5 years ago

@csulit try req.user.phone or console.log(req.user)

csulit commented 5 years ago

Hi, phone is not in the same document btw thank you for your reply i already find out how to fetch data and render to view.