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

Revalidate cookies on update #23

Open
eyyMinda opened this issue Dec 14, 2023 · 0 comments
Open

Revalidate cookies on update #23

eyyMinda opened this issue Dec 14, 2023 · 0 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@eyyMinda
Copy link
Owner

eyyMinda commented Dec 14, 2023

Need to implement a logic where user data stored in cookies would be updated client side, most likely after each hard refresh (If i am able to programmatically differentiate that is).

Update:

Use MongoDB Change Streams to implement listeners on the current profile object.

const collection = db.collection('inventory');
const changeStream = collection.watch();
changeStream.on('change', next => {
// process next document
// revalidate session
});

Revalidate session once change stream detects a change in user object: username, profile pic

Issue reproduction example:

  • Login to the website in one browser (ex. Chrome)
    Name displayed (ex.) John

  • Open a new browser or tab variation that does not contain the same cookies and login there as well (ex.) Brave
    Initially name is also (ex.) John

  • Change the name to Smith in (ex.) Brave browser
    In (ex.) Brave browser name is updated immediately, displays Smith

  • Go back to previous browser where you are still logged in due to jwt cookie auth (ex.) Chrome
    Name displayed John

@eyyMinda eyyMinda added the enhancement New feature or request label Dec 14, 2023
@eyyMinda eyyMinda added the documentation Improvements or additions to documentation label Dec 17, 2023
@eyyMinda eyyMinda changed the title Revalidate cookies on hard refresh Revalidate cookies on update Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
Status: In Progress
Development

No branches or pull requests

1 participant