User Authentication Using JWT token
This project is the User Authentication operation. such as Userlogin, Usersignup, GetUserProfile, DeleteUser, Userlogout, and UserUpdate. Any project requires an Authorized mechanism. For example, if you create an e-commerce website or application, you’ll need this LoginModel to store all customer data.
Functionality :
When someone visits your app for the first time, they must first create an account and then log in to your app. Only go to the home page if the user is logged in; otherwise, do not. This type of functionality is commonly found in real-time applications. This is a login model with a JWT token that is being tested with the Jest package. The main operations in this app are Create, Read(Get), Update, and Delete. All operations are linked to a JWT token, which means that once you log in to your app, you can only perform other operations such as get, update, delete, and so on.
Flowchart :
1. SignUP API
The user is Creating the Account with our own Parameter and using SignUpAPI. User SignUpAPI is a Post request. In this app, the user is creating an account with name, email, password, and age. once you send the SignUp Request that time whole data is stored in MongoDB DataBase With JWT Token. When the User is Create an account Then Only Allowed to log in.
2. Login API
User LoginAPI is a Post request. The user Login With Candrenial And token which is created by signUp request. In This App login API with email, password, and JWT Token Which Generate by User When the User is Create an account. when the user is sending a login request that compares both JWT Tokens, once both tokens are the same then only the user login successfully otherwise not allowed to log in.
3. Profile API
The user profile API is Get request. When the user is logged in then only you can get your profile otherwise get an error like “you first please authentication”. when the User sends a ProfileAPI request that time API response is your Parameter, which uses in SignUpAPI. In this App, the User gets a name, email, age, etc.
4. Update API
User Update Profile is Patch or Put request. When the user is logged in then only you can update your profile otherwise get an error like “you first please authentication”. The user sends a UpdateAPI request at that time API response is your Parameter, which the User update. In this App User updated parameter is name, email, age, etc.
5. Delete API
User Delete is a delete request. when the user is logged in then only you can delete your account otherwise get an error like “you first please authentication”. User Send DeleteAPI request at that time response is like “User is Delete Successfully” and the user is Delete from the database.
6. Logout API
User Logout is a post request. when the user is logged in then only you can log out of your account otherwise get an error like “you first please authentication”. The user sends a logout API request at that time response is like “User is Logout In your app Successfully” and the user is logout from the app not deleted from the database.