TypeError: Object #<Strategy> has no method 'findByUsername'

I'm attempting to use passport-local as follows:

users.js:

var Users = function() {}
Users.prototype.findByUsername = function(username, cb) {
    var user = { name: username };
    cb(null, user);
};
Users.prototype.verify = function(username, password, done) {
    this.findByUsername(username, function(err, user) {
        done(null, user);
    });
};

module.exports = Users;

In app.js:

var Users = require('./users');
var users = new Users();

passport.use(new LocalStrategy(users.verify));

When I attempt to log in, I get TypeError: Object #<Strategy> has no method 'findByUsername'.

I'm new to Javascript (and node.js), but I've done some searching, and I think I'm using the constructor pattern correctly.

So why is this set to an instance of Strategy, rather than an instance of Users?

In the line

passport.use(new LocalStrategy(users.verify));

you are passing the function to LocalStrategy which changes it's context (functions are first class citizens in JavaScript). this no longer points to the User object but to the Strategy. Hence you need to bind your function to the Users context.

A bit of wild guess suggestion:

Users.prototype.verify = function(username, password, done) {
    this.findByUsername(username, function(err, user) {
        done(null, user);
    });
}.bind(Users.prototype);