Sunday, 9 April 2017

Trying to understand Node JS routing code

I am trying to understand one of the open source implementations to achieve SAML based SSO and I am having trouble understanding the following express router method from this class:

router.get('/', function(req, res, next) {
  console.log(arguments);
    if(req.isAuthenticated()){
        res.render('index', {
            title: 'sp1 - My Application',
            user: req.user
        });
    }else{
      console.log('not authentcated sending to authenticate');
        res.redirect('/login');
    }
});

My question is :

where exactly the code is setting `isAuthenticated` flag to true or false?

When I launched /login for the first time, I see it being false but again when I get a redirect from my idp (identity provider) this flag is true and I am going inside the if condition.



via nitinsh99

No comments:

Post a Comment