What is “done” callback function in Passport Strategy Configure “use” function

前端 未结 1 885
执笔经年
执笔经年 2020-12-23 11:43

I\'m an node.js and express.js noob. This question may seems silly but I\'m really in confusion.

I\'m trying to configure Local Strategry authentication by using pas

相关标签:
1条回答
  • 2020-12-23 12:42

    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.

    0 讨论(0)
提交回复
热议问题