21 July 2023
So the project I started is a Fullstack project. I'll be making a login system using MERN. I have previously made a login system so I have a pretty good idea of how things will work in the backend. The main focus of this project is to learn how to connect the server with the client.
Packages I used in the backend:
Working:
I'll be getting data from the client in JSON format.
If the user is new then he will be using the 'register' route but if the user has already registered then he will use the 'login' route.
We will do some validation before storing the data.
If everything is all right then we will Hash the password using bcryptjs to increase the security of our database.
Just before storing the data, we will create a jwt token which we will send using a cookie to authenticate the user.
A token will be created every time the user register or login.
We will authenticate the user using middleware in the routes it is necessary to authenticate.
Whenever the 'logout' route is called we will delete the cookie from the browser and also delete the token generated by the browser.