passport: TypeError: done is not a function

I’m trying to use an OAuth1.0 provider, and after calling done in the verify function the serialization fails

passport.serializeUser = (user,done) ->
    done(null,user)
passport.deserializeUser = (obj,done) ->
    done(null,obj)
TypeError: done is not a function
    at Authenticator.passport.serializeUser (/app/scripts/jira.coffee:22:2, <js>:24:12)

any thoughts?

About this issue

  • Original URL
  • State: open
  • Created 9 years ago
  • Reactions: 3
  • Comments: 21

Most upvoted comments

+1

In my case is when using LocalStrategy, the error goes away when removing options (passReqToCallBack: true)

passport.use(new LocalStrategy({
  passReqToCallBack: true
},
  (username, password, done) => {
    User.findOne({ username }, (err, user) => {
      if (!user || !bcrypt.compareSync(password, user.password)) {
        done(null, false);
        return;
      }
      done(null, user);
    });
  }
));

Found what was causing my case of done is not a function. When using passReqToCallback: true the parameters need to be updated:

function(req, username, password, done)

Hey guys,

Is this about passing extra parameter from the form to the passport.js? I used req.body.<fieldname> to pass extra field like ‘Role’ and used that in my code. That way I didn’t have to edit the passport’s code and I was able to add that information in my mongo database.

I might be sounding completely stupid but this is what I understood from your discussion above.

Abi