AllenYuan

pass user

May 9th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //...
  2. router.get('/:username', auth.optional, function(req, res, next) {
  3.   // if the profile is being navigated to by a logged in user,
  4.   if (req.payload) {
  5.     User.findById(req.payload.id).then(function(user) {
  6.       if (!user) { return res.json({profile: req.profile.toProfileJSONFor(false)}); }
  7.  
  8.       return res.json({profile: req.profile.toProfileJSONFor(user)});
  9.     });
  10.   } else {
  11.     return res.json({profile: req.profile.toProfileJSONFor(false)});
  12.   }
  13. });
  14. //...
Add Comment
Please, Sign In to add comment