2
I am creating my first application in Nodejs and managed to structure the application, connection, directory structure, routes, in short, everything working right.
Now, I went to implement the login system and I’ve come across an error in the passage of the parameters to the passport.use(new LocalStrategy(function(email,password,done)){});
.
I’m trying to call two properties passed as parameters, but it’s giving error:
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var userService = {
//Se eu der um console.log() aqui, aparece os valores passados.
login: function(email,password) {
//O problema está aqui, quando tento passar o email e o password como parâmetro.
passport.use(new LocalStrategy(function(email, password, done) {
console.log(email); //Aqui não imprime mais
});
},
}
Could help me figure out how to pass the parameter into the passport.use
?
Thanks in advance.
I don’t know how to answer you (because I don’t know Nodejs/Express) but I can infer from your code that at no time are you going through
email
andpassword
as arguments. The parameters of your anonymous functionemail
,password
anddone
have nothing to do with the parametersemail
andpassword
of functionlogin
. They are totally different variables. Whatever the correct way to pass them, this is certainly not it. P.S. Second that documentation if your username is notusername
an additional pro argument is requiredLocalStrategy
.– mgibsonbr
Managed to solve?
– durtto