I have a function inside an if statement
isLoggedin() has an async call.
router.get('/', function(req, res, next) {
    if(req.isLoggedin()){ <- never returns true
        console.log('Authenticated!');
    } else {
        console.log('Unauthenticated');
    }
});
how do i await for isLoggedin() in this if statement?
here is my isLoggedin function in which im using passport
app.use(function (req, res, next) {
   req.isLoggedin = () => {
        //passport-local
        if(req.isAuthenticated()) return true;
        //http-bearer
       passport.authenticate('bearer-login',(err, user) => {
           if (err) throw err;
           if (!user) return false;
           return true;
       })(req, res);
   };
   next();
});
 
     
     
    