0
I am trying to implement the authentication system on my platform using Passport, Passport-local and Passport-local-Mongoose.
I was able to apply login authentication:
app.post("/login", passport.authenticate("local", {
successRedirect: "/secret",
failureRedirect: "/login"
}) ,function(req, res){
});
But I cannot understand the authentication structure when registering a new user:
app.post("/register", function(req, res) {
User.register(new User({username: req.body.username}), req.body.password, function(erro, user) {
if(erro) {
console.log(erro);
return res.render("register");
}
passport.authenticate('local')(req, res, function () {
res.redirect("/secret");
});
});
});
Because the structure that will redirect after user authentication has this structure: passport.authenticate("local")(req, res, function(){}
I cannot understand the role of these next parentheses. What role do they play?