, passport.authenticate , , , , , - .
, - :
app.get("/auth", passport.authenticate('facebook-token',function(){...});
app.get("/public1",...);
app.post("/public2",...);
app.get("/private1", function(req,res,next){
if (req.isAuthenticated()){
}else{
res.redirect("/auth");
}
});
, , , , .
, , .
-
function isThisGuyAuthenticated(req,res,next){
if (req.isAuthenticated()){
return next();
}else{
res.redirect("/auth");
}
}
:
app.get("/private1",isThisGuyAuthenticated, doCrazySecretStuff);
app.get("/private2", isThisGuyAuthenticated, getCocaColaRecipe);
app.get("/private3", isThisGuyAuthenticated, flyToMars);
app.get("/public", showInfo);
, , isThisGuyAuthenticated ( passport.authenticate !);
app.get("/auth", passport.authenticate('facebook-token',function(){...});
app.use(isThisGuyAuthenticated);
app.get("/private1", doCrazySecretStuff);
app.get("/private2", getCocaColaRecipe);
app.get("/private3", flyToMars);
?
: "/auth". ,