Custom autorization in nodeBB



  • I am trying to make the authorization for nodebb by link. I try to use the strategy passport-http-bearer

    var Strategy = require('passport-http-bearer').Strategy;
    var passport_two = require('passport');
    passport_two.use(new Strategy(
      function(token, cb) {
        //db.users.findById(token, function(err, user) {
         // if (err) { return cb(err); }
        //  if (!user) { return cb(null, false); }
          return cb(null, 1); // where 1 number user for example
        });
      }));
    app.get('/secret', 
      passport_two.authenticate('bearer', { session: true }),
      function(req, res) {
        res.json(req.user);
    });
    

    but there is no authorization. Why?

    How I can authorization a user on the site by email or id?


  • Admin

    Is this a plugin in NodeBB? You'll need to add the routes by listening to the static:app.init hook.


Log in to reply
 


Looks like your connection to NodeBB was lost, please wait while we try to reconnect.