I'm 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 can not 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 make redirection after user authentication has this structure: passport.authenticate("local")(req, res, function(){}
I can not understand the role of these parentheses. What is their role?