how do you redirect a user who is not logged in using passport authentication

  javascript, passport.js, reactjs

trying to stop a user from accessing my /mainpage route if they arent logged and to redirect them to login…. currently using passport and react router and components… here is my app js

    return (
      <Router>
      <div>
          <Route exact path="/" component={Login} />
          <Route exact path="/login" component={Login} />
          <Route exact path="/signup" component={Signup} />
          <Route exact path="/mainpage" component={MainPage} />
          <Footer />
      </div>
    </Router>
    );
  }
export default App;

this is the html-routes.js part im trying to make work

app.get("/mainpage", isAuthenticated, (req, res) => {
    res.sendFile(path.join(__dirname, "/signup.html"));
  });

Source: Ask Javascript Questions

LEAVE A COMMENT