jaredhanson / passport-local

Username and password authentication strategy for Passport and Node.js.
https://www.passportjs.org/packages/passport-local/?utm_source=github&utm_medium=referral&utm_campaign=passport-local&utm_content=about
MIT License
2.73k stars 497 forks source link

can't use it for multi users on multi dbs #78

Open ohadperry opened 10 years ago

ohadperry commented 10 years ago

Hi, my service serves more then one app. Meaning he provides login/signup services for more then one clients who has a different db. How do I use the simple local strategy to save to a different db every time??

passport.use(new LocalStrategy({ usernameField: 'email' }, function(email, password, done) {
    User.findOne({ email: email }, function(err, user) {
        if (!user) return done(null, false, { message: 'Email ' + email + ' not found'});
        user.comparePassword(password, function(err, isMatch) {
            if (isMatch) {
                return done(null, user);
            } else {
                return done(null, false, { message: 'Invalid email or password.' });
            }
        });
    });
}));
shlima commented 10 years ago

+1

GochoMugo commented 9 years ago

Do you mind giving a more elaborate example?