SHARE
TWEET

Untitled

a guest Oct 10th, 2019 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import passport from 'passport';
  2.  
  3. module.exports = app => {
  4.   app.get('/findUser', (req, res, next) => {
  5.     passport.authenticate('jwt', { session: false }, (err, user, info) => {
  6.       if (err) {
  7.         console.log(err);
  8.       }
  9.       if (info != undefined) {
  10.         console.log(info.message);
  11.         res.send(info.message);
  12.       } else {
  13.         console.log('user found in db from route');
  14.         res.status(200).send({
  15.           auth: true,
  16.           first_name: user.first_name,
  17.           last_name: user.last_name,
  18.           email: user.email,
  19.           username: user.username,
  20.           password: user.password,
  21.           message: 'user found in db',
  22.         });
  23.       }
  24.     })(req, res, next);
  25.   });
  26. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top