I am new to node js. I am trying to make an app similar to Udemy, byjus, where a user who buys the video can only play course video . But rest who have not bought the course can just view the page . My question is how to give the user a permanent access or authority (may be a permanent token) after the payment only .
First off, the user would typically have a login (username and password).
Then, after they pay for access to some content, you can assign privileges to the user in your back-end data store. This would be a permanent record that they are allowed access to a particular resource or set of resources.
For any page that requires a privilege before viewing, you would check if the current logged-in user has that privilege before letting then see that particular content. If not, you would render them some generic page (probably informing them how they can pay for access to this content).
This way, the only thing that a user has to keep track of is their login name and password and your server keeps track of what privileges they have paid for. The user could view their content from any device without having to write down or remember or store any particular tokens.