So I have just built a simple ecommerce app using using react in the frontend,node in the backend and mongodb as a database.
I built this project for learning purpose.
So I thought of building a demo user login feature in the app.
This is to make anyone who enters the page have a passwordless login.When clicked on the demo login button the person should be able to login as normal user or admin user.
So if the admin login is too public then whoever that visits that site can make as much changes as they like.So it could destroy the whole application.
So I want it to work in such a way that the demo admin login session should only be available for 15 minutes.That I can do easily by setting up the expiry in JWT.
But the trickier part is that I do not want to store the changes made by the demo admin user permanently. After the demo admin has logged out I want to switch the state of the database to the previous state.So basically what I want to do is revert back all the changes done by demo admin user.
So how could i achieve this ? My current plan was that only 1 person could login as a demo admin user at a time.Their session would be active for 15 minutes.So before the demo admin login I would make a backup of all the data in the mongodb database.It is hosted on mongodb atlas.Then after the 15 minutes period I would delete all the data and restore everything from backup.
But is this the most feasible way ?
Its the only solution I came up with.So if anyone have any ideas please let me know.