Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unauthorized access with "←" button #19

Open
basuabhirup opened this issue Sep 17, 2021 · 2 comments
Open

Unauthorized access with "←" button #19

basuabhirup opened this issue Sep 17, 2021 · 2 comments

Comments

@basuabhirup
Copy link

Some of our fellow students have found that even after logging out from the app - the cookies continue to remain saved inside the browser, making the secrets page accessible with the / Back / Previous Page button of the browser.

What we need is to control the Cache and prevent them from getting stored inside the user's browser. I have a suggestion to modify the handler function of GET requests made on the /secrets route to fix this issue:

app.get('/secrets', (req, res) => {
  res.set('Cache-Control', 'no-store');
  if(req.isAuthenticated()) {
    res.render('secrets');
  } else {
    res.redirect('/login');
  }
})

Know more about cache control.

@sundaram2021
Copy link

I didn't get the Issue

@Crazyhead90
Copy link

Crazyhead90 commented Feb 6, 2022

Simply adding a isAuthenticated check will also solve the direct access to the secrets

app.get("/secrets", function(req, res){
  if(req.isAuthenticated()) {
    User.find({"secret": {$ne: null}}, function(err, foundUsers){
      res.render('secrets', {usersWithSecrets: foundUsers});
    })
  } else {
    res.redirect('/login');
  };
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants