简体   繁体   中英

Set isAuthenticated true in Passport.js | skip login

I searched a lot, I'm still not sure if someone already asked this, if so, I am sorry. First of all I'm new to this, sorry if it's a stupid question and thanks in advance.

I'm using Passport middleware for authentification and everything works as intended. But now I want to skip the log in part for show purposes. Is there any possibility to immediately set Authentication to true and skip the log in part through that? Or do i have to remove the whole passport thing?

If I just redirect to next page it gets an error because of undefined data. Thanks for any kind of serious help.

if (req.headers.host.indexOf("local")==0){
   req.login(new User({username: "xxx"}), function(err) {
      if (err) { 
          return next(err); 
      }
          return next();
      });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM