1

I have a login system, node.js ofc and working with ejs, but this login system is different and can't be altered Here's my login code

// DOES A HTTP POST TO LOGIN SERVER 
if (code.data == "201") {
  let uid = req.body.uid;
  res.render('dashboard', { name, uid })
}
if (code.data == "403") {
  console.log('Invalid Creds!')
}
if (code.data == "404") {
  console.log('User not found')
}

Now I have a few app.get function that redirects to other pages from the dashboard, but here's the part where i need help, now when a user is redirected to a new page he gets redirected just fine but the issue is the person who isn't logged in also gets access!

app.get('/new', (req, res) => {
  res.render('new')
})

Another thing, 2 things from the login are sent to the dashboard, now the same data should be sent to the next page, in our case it is a /new

People have asked me to use a passport system but I just couldn't get it to work

I've been trying for weeks (more than 6) but couldn't figure it out, someone please help :(

pTools
  • 31
  • 4
  • 1
    There is no user login validation is checked resulting any user getting redirected. This will be helpful https://stackoverflow.com/questions/42282448/login-authentication-in-nodejs – Rishab Apr 29 '21 at 14:07

0 Answers0