title: ReferenceError: Users is not defined
body: <p>This is a very specific question, but I really don't know what is causing the error. I have the following code:</p>
  
  <pre><code>router.get('/user/profile', passport.authenticate('jwt', { session: false }), function(req, res, next){
  // Something
  });
  </code></pre>
  
  <p>When I access the route it goes through my passport-jwt code that includes my custom getUserById() function, that is defined in the users model</p>
  
  <pre><code>let opts = {};
  opts.jwtFromRequest = ExtractJwt.fromAuthHeaderWithScheme('jwt');
  opts.secretOrKey = config.secret;
  passport.use(new JwtStrategy(opts, function(jwt_payload, done){
      Users.getUserById(jwt_payload._id, function(err, user){
          if(err){
              return done(err, false);
          }
  
          if(user){
              return done(null, user);
          } else {
              return done(null, false);
          }
      });
  }));
  </code></pre>
  
  <p><strong>getUserById()</strong></p>
  
  <pre><code>module.exports.getUserById = function(id, callback){
      Users.findById(id, callback);
  }
  </code></pre>
  
  <p>When I access the route my server spits out the following error:</p>
  
  <pre><code>ReferenceError: Users is not defined
      at Function.module.exports.getUserById (E:\Projects\CSGOOrb\models\users.js:55:2)
      at JwtStrategy._verify (E:\Projects\CSGOOrb\config\passport.js:18:9)
      at E:\Projects\CSGOOrb\node_modules\passport-jwt\lib\strategy.js:123:34
      at E:\Projects\CSGOOrb\node_modules\jsonwebtoken\verify.js:27:18
      at _combinedTickCallback (internal/process/next_tick.js:131:7)
      at process._tickCallback (internal/process/next_tick.js:180:9)
  </code></pre>
  
  <p>I have required my user model in all files that make use of it. Does anyone know what else could be causing it?</p>
  
  <p><strong>EDIT:</strong> </p>
  
  <p><strong>passport.js</strong></p>
  
  <pre><code>const colors = require('colors/safe');
  const Users = require('../models/users');
  const config = require('../config/database');
  
  const jwt = require('jsonwebtoken');
  const JwtStrategy = require('passport-jwt').Strategy;
  const ExtractJwt = require('passport-jwt').ExtractJwt;
  const SteamStrategy = require('passport-steam').Strategy;
  
  module.exports = function(passport){
  
      let opts = {};
      opts.jwtFromRequest = ExtractJwt.fromAuthHeaderWithScheme('jwt');
      opts.secretOrKey = config.secret;
      passport.use(new JwtStrategy(opts, function(jwt_payload, done){
          Users.getUserById(jwt_payload._id, function(err, user){
              if(err){
                  return done(err, false);
              }
  
              if(user){
                  return done(null, user);
              } else {
                  return done(null, false);
              }
          });
      }));
  ...
  </code></pre>
  
  <p><strong>users.js (Mongoose Model)</strong></p>
  
  <pre><code>const mongoose = require('mongoose');
  const config = require('../config/database');
  
  // Users Schema
  const UsersSchema = mongoose.Schema(
      {
          admin: {
              type: Boolean,
              default: false
          },
          mod: {
              type: Boolean,
              default: false
          },
          user: {
              type: Boolean,
              default: true
          },
          steam: {
              id: {
                  type: String
              },
              identifier: {
                  type: String
              },
              name: {
                  type: String
              },
              avatar: {
                  type: String
              },
              avatarmedium: {
                  type: String
              },
              avatarfull: {
                  type: String
              },
              tradelink: {
                  type: String
              }
          }
      },
      {
          timestamps: 
          { 
              createdAt: 'created_at',
              updatedAt: 'updated_at' 
          }
      }
      );
  
  const Users = module.exports = mongoose.model('User', UsersSchema);
  
  module.exports.getUserById = function(id, callback){
      Users.findById(id, callback);
  }
  
  module.exports.getUserById64 = function(id, callback){
      const query = {id: steam.id};
      Users.findOne(query, callback);
  }
  </code></pre>