1

So my project has 3 dashboards for client, admin and employee. All the three have different functionalities and options. (a little bit change)

All 3 login with same login page that is : localhost:3000/login and all the 3 dashboards are dependent on each other. Suppose client add some tasks in his dashboard then admin approves it via his respective dashboard and then the employee updates the task status via his dashboard that is also being updated on the other 2 dashboards.

So to check all the functionalities parallely, I logged in all on 3 separate localhost:3000/login tabs in same Google Chrome for testing purpose instead of logging in again and again serial wise and checking if the data is being updated.

But by doing with separate dashboards, the data some-while gets mismatched and not updated. So I am thinking that after deploying the code will that be a problem when all the 3 users will login simultaneously and start making changes? Will it work fine after deployment or is it just on localhost.

Here is the login code in nodejs I am using for all users:

router.route('/login')
  .get(function(req, res, next) {
    res.render('login', { title: 'Login your account'});
  })
  .post(passport.authenticate('local', {
    failureRedirect: '/login'
  }), function (req, res) {
    if(req.user.tag == 'Emp')
    res.redirect('/profileEmp');
    else if(req.user.tag == 'Admin')
    res.redirect('/profileAdmin');
    else {
      res.redirect('/profile');
    }
  //  console.log(req.user.email);
  });

P.S. All dashboards work fine when I make changes with one dashboard login only and then again I logout and login to another dashboard say Employee one; it works fine.

O. Jones
  • 103,626
  • 17
  • 118
  • 172
Biku7
  • 450
  • 6
  • 16

1 Answers1

1

I guess you have three different login credentials, one for each role.

The way logged in session management usually works is this: upon accepting a set of credentials the passport module feeds a session cookie to your browser.

If you log in as user and then, from the same browser as admin, the admin session cookie overwrites the user session cookie. That browser (all its tabs) is now logged in as admin.

There's a Chromium web extension called EditThisCookie. It lets you see, easily, the cookies for each page. Use it to troubleshoot this kind of thing.

I use three separate browsers, Chrome, Firefox, and Edge or Safari, to debug this kind of thing. I can keep separate sessions separate by running them in separate browsers.

O. Jones
  • 103,626
  • 17
  • 118
  • 172
  • Thanks! @O. Jones. So yes what you said I think that is what happening. Also does it mean that this issue won't be faced by the actual multiple users while logging simultaneously since they will login with their browser. – Biku7 Sep 09 '20 at 12:48
  • Yes, generally individual users have their own browsers, and their own session cookies. It's only when testing multiple different user logins at once this comes up. – O. Jones Sep 09 '20 at 15:38