简体   繁体   中英

Baucis + Node.js

Good day everyone! I have some problems with understanding baucis ( https://github.com/wprl/baucis ). In middleware section I found that request can have isAuthenticated() method, but I'm not found any information about it in documentation and I got mistakes when called it. I need to realize this method in my code by myself? My code:

var citySchema = new mongoose.Schema({
  name: String
});

mongoose.model('City', citySchema);

var citiesController = baucis.rest('City');

citiesController.request(function (req, res, next) {
  if (req.isAuthenticated()) return next();
  return res.send(401);
});

Thanks for your question.

That is non-runnable example code. The passport middleware module adds the isAuthenticated method to request, though with baucis you are free to use whatever authentication middleware you would like.

HTH!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM