passport local strategy not getting called

前端 未结 14 780
夕颜
夕颜 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:55

    I also banged my head for the same problem for few hours. I was having everything in place as told by other answers like 1. Form was returning all fields. 2. body parser was setup correctly with extended:true 3. Passport with every setting and configuration.

    But i have changed username field with phoneNumber and password. By changing code like below solved my problem

      passport.use('login', new LocalStrategy(
        {usernameField:'phoneNumber',
        passwordField:'password'},
        function (username, password, done) {
    
        // your login goes here
        })
    

    );

    If anyone want i can write the whole authentication procedure for phonenumber using mongodb and passport-local.

    Thanks @user568109

提交回复
热议问题