I want to make a demonstration system quickly. Due to the lack of background, I want to build it myself using nodejs.
Although they are all static pages, the login function needs to be completed (no registration is required, the password can be assigned directly to the database), and the jump can only be made after logging in. Go to the homepage of the page. If you enter the homepage path directly without logging in, it will jump to the login page.
Because I am a novice and I don’t know how to do it. Please help me with the direction and how to complete it quickly
You need koa and koa-router
You can use express session and then write a checkLogin method to determine whether !req.session.user is logged in. Then write a checkNoLogin method and judge req.session.user.
I won’t write the html for you, the basic form content
JS ajax request:
If you don’t understand the code below, you can refer to /a/11...
Access to subsequent pages must have session information. You can make requests to the background on each page. Then you use node to detect the session content, and then ajax takes action. The general idea is this, I am also a novice, I hope I can help you.