Hi, for a web development project, I want to make a login page on my website, but I don't know how to create a session, and compare the login with my .json.
I tried to do my login system with passport, express-session ans socket.io, but I didn't succeed. I don't understand the logic required.
Could someone please help me ? Explain to me the logic ? Show me an example code which help me ?
Top comments (1)
Normally, first you check the credentials, then you create a JWT and return it (you can set a cookie for it).
Then in each endpoint you require auth, you get that token, parse and validate to get it content (claims).
There is more things to get done, like expiration dates, refresh tokens, etc. So I recommend using a service like auth0.