Express interceptor

https://cnodejs.org/topic/512d8172df9e9fcc58333c73
login interception at the Express Nodejs + realization

app.js in:

// ----------- interceptor implementation --------------------------------- ----
var OpenPage = [ '/', '/ Users / zhuce', '/ Users / Login', '/ Users / Zimbabwe Logout'];

app.use(function(req, res, next) {
  var url = req.originalUrl;
  if(openPage.indexOf(url)>-1){
    next();
  }else{
    if(req.session.loginbean){
      next();
    }else{
      res.redirect('/');
    }
  }
});
//-------------------------------------------------------------

Guess you like

Origin www.cnblogs.com/xintao/p/11652685.html
Recommended