LAB 8 JSON Web Token - sindhusha-t/ASE-Lab-Assignments GitHub Wiki
LAB 8 Basic Login using angular and JSON Web Token
Introduction:
Creating basic login and registration pages where authorization to the home pages is done using JSON web token.
Main Objective:
Task-1: Creating backend server API that listens on port 4000 and verifies the JSON web token.
-
Installed the following packages using npm.
npm new app_name
npm init
npm install express jsonwebtoken
npm install nodemon
-
Creating server backend API that listens to the routers on 5000
-
code for creating the token from user name and email ID
-
Code for getting the user details in the JSON format after verifying the web token
-
Function to verify the bearer token key and also opens the port 4000 to listen for GET or POST requests.
Task-2: Creating login and home page.
- Function that contacts Model( Backend API) for creating the token after authorization.
- Functions that contacts backend API for verifying the token and returning the required user details.
User Interface - Output
-
Running ng serve
-
Running nodemon for backend server API service
-
Registration page:
-
Login Page:
-
Home page:
-
Display authorized user details
Conclusion: We have learnt how to authorize the user using JSON Web Token.