passport-local icon indicating copy to clipboard operation
passport-local copied to clipboard

can't use it for multi users on multi dbs

Open ohadperry opened this issue 11 years ago • 2 comments

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.' });
            }
        });
    });
}));

ohadperry avatar May 25 '14 18:05 ohadperry

+1

shlima avatar Sep 03 '14 21:09 shlima

Do you mind giving a more elaborate example?

GochoMugo avatar Jun 14 '15 18:06 GochoMugo