DEV Community

Mustafa  Çam
Mustafa Çam

Posted on

Answer: Multiple Passport LocalStrategies

You can do it by having 2 different LocalStrategies to authenticate user and admin differently (in your case from different tables).

Something like :

passport.use('user', new LocalStrategy(  //'user' strategy
  function(username, password, done) {
    User.findOne(/* ... */)
  }
));

passport.use('admin', new LocalStrategy( //'admin' strategy
  function(username, password, done) {
    Admin.findOne(/* ... */)

Top comments (0)