LinkM LinkM - 7 months ago 30
Javascript Question

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.

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