<."/> <."/> <"/>
خرید بک لینک

Vote count: 0

In a MEAN application, I have a Facebook button on a modal window:

<a href="users/facebook" class="btn btn-primary"><span class="fa fa-facebook"></span> Facebook</a>

The routes target is:

router.get('/facebook', passport.authenticate('facebook'),
  function(req, res){});
router.get('/facebook/callback', function(req,res,next){
  passport.authenticate('facebook', function(err, user, info) {
    if (err) {retu next(err);}
    if (!user) {retu res.redirect('/login');}
    req.logIn(user, function(err) {
      if (err) {retu next(err);}
        //res.locals.user = req.user;
        retu res.redirect('/');       
    });
  })(req,res,next);
});

I want to retu the useame to the main view and I have tried adding:

app.use(function(req, res, next){
  res.locals.user = req.user;
  next();
});

which I thought would make a user variable available in the views but no user variable exists in the views.

asked 4 mins ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 9 خرداد 1395 ساعت: 12:36

صفحه بندی