text: // const LocalStrategy = require('passport-local').Strategy;
  // const bcrypt = require('bcryptjs');
  
  // // Load User model
  // const User = require('../models/User');
  
  // module.exports = function(passport) {
  //   passport.use(
  //     new LocalStrategy({ usernameField: 'email' }, (email, password, done) => {
  //       // Match user
  //       User.findOne({
  //         email: email
  //       }).then(user => {
  //         if (!user) {
  //           return done(null, false, { message: 'That email is not registered' });
  //         }
  
  //         // Match password
  //         bcrypt.compare(password, user.password, (err, isMatch) => {
  //           if (err) throw err;
  //           if (isMatch) {
  //             return done(null, user);
  //           } else {
  //             return done(null, false, { message: 'Password incorrect' });
  //           }
  //         });
  //       });
  //     })
  //   );
  
  //   passport.serializeUser(function(user, done) {
  //     done(null, user.id);
  //   });
  
  //   passport.deserializeUser(function(id, done) {
  //     User.findById(id, function(err, user) {
  //       done(err, user);
  //     });
  //   });
  // };
  
  
  const JwtStrategy = require('passport-jwt').Strategy;
  const ExtractJwt = require('passport-jwt').ExtractJwt;
  
  // const control = require('../controls/controller');
  // const config = require('../config/database');
  
  
  module.exports = function(passport) {
    let opts = {};
    opts.jwtFromRequest = ExtractJwt.fromAuthHeaderWithScheme('jwt');
    opts.secretOrKey = process.env.JWT_SECRET;
    passport.use(new JwtStrategy(opts, (jwt_payload, done) => {
      console.log('amosmoyo', jwt_payload);
      getUserById(jwt_payload.data._id, (err, user) => {
        if(err) {
          return done(err, false);
        }
  
        if(user) {
          return done(null, user);
        } else {
          return done(null, false);
        }
      });
    }));
  }
  
  const getUserById = function(id, callback) {
    User.findById(id, callback);
  }
  