express - Passport-jwt token get error messages from server -


i cannot figure out how pass error messages server client. searched docs, cannot should implement callback function return error message.

my server-side code looks this:

passport.js

var locallogin = new localstrategy(localoptions, function(email, password, done){  user.findone({   email: email  }, function(err, user, info){  if(err){   return done(err); }  if(!user){   return done(null, false, {message: 'user not found'}); }  user.comparepassword(password, function(err, ismatch){    if(err){     return done(err);   }    if(!ismatch){     return done(null, false, {message: 'passwords not match'});   }    return done(null, user);  });  });  }); 

router.js

> var requireauth = passport.authenticate('jwt', {session: false}), >     requirelogin = passport.authenticate('local', {session: false}); >  > module.exports = function(app){ >  >   var apiroutes = express.router(), >       authroutes = express.router(), >       todoroutes = express.router(); >  >   // auth routes   apiroutes.use('/auth', authroutes); >  >   authroutes.post('/register', authenticationcontroller.register);   > authroutes.post('/login', requirelogin, authenticationcontroller.login); 

in client receive error message.

response {_body: "unauthorized", status: 401, ok: false, statustext: "unauthorized", headers: headers…}headers: headersok: falsestatus: 401statustext: "unauthorized"type: 2url: "http://localhost:8083/api/auth/login"_body: "unauthorized"__proto__: body 


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -