¿qué es req.IsAuthenticated () PassportJS [cerrado]


En la documentación de Passport, creo que la función de pasaporte autenticado no está bien documentada.

Quiero preguntar, ¿qué pasaporte.IsAuthenticated () id do?

Author: Kim, 2016-08-08

1 answers

Para cualquier solicitud puede comprobar si un usuario está autenticado o no utilizando este método.

app.get('/some_path',checkAuthentication,function(req,res){
    //do something only if user is authenticated
});
function checkAuthentication(req,res,next){
    if(req.isAuthenticated()){
        //req.isAuthenticated() will return true if user is logged in
        next();
    } else{
        res.redirect("/login");
    }
}
 51
Author: nrgwsth,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-04-08 07:46:46