What is "done" callback function in Passport Strategy Configure "use" function What is "done" callback function in Passport Strategy Configure "use" function express express

What is "done" callback function in Passport Strategy Configure "use" function


done is a method called internally by the strategy implementation.

Then it navigates you, as you can see, to one of the success / error / fail methods (again, by the implementation. there are more options).Each of these options may calls to the next, where in your snippet code is the following:

function(req, res) {  res.redirect('/');});

When success is called, it can attach the user to the request or do other things, depending on your needs (it looks for the options you pass to passport.authenticate). If you want to determine when next will be called, you should use custom callback which gives you more flexibility.

I strongly recommend that you read the source.