passport local strategy not getting called

前端 未结 14 802
夕颜
夕颜 2020-12-13 04:31

I\'m sure I\'m missing something really obvious here, but I can\'t figure this out. The function I\'ve passed to the LocalStrategy constructor doesn\'t get called when the l

14条回答
  •  盖世英雄少女心
    2020-12-13 04:58

    You get 401 when you using different username, password input fields than the default ones. You have to provide that in your LocalStrategy like this :

    passport.use(new LocalStrategy({
        usernameField: 'login',
        passwordField: 'password'
      },
    
      function(username, password, done) {
      ...
      }
    ));
    

    Default is username and password I think. See the docs here.

提交回复
热议问题