Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Where do i store my login credentials in angularjs?


Asked by Santana Peterson on Nov 29, 2021 AngularJS



As the user enters login credentials and clicks on the login button we authenticate the user and redirect them to user home page. We store the user data in angularjs scope object and binding it to the variable.
Likewise,
As the user enters login credentials and clicks on the login button we authenticate the user and redirect them to user home page. We store the user data in angularjs scope object and binding it to the variable. If can also authenticate user with their registered credentials in database using a webservice or API that talks to database server.
Also, In our previous discussions, we have covered what is AngularJS, basic building blocks , Dependency Injection, and Routing in AngularJS. For a user to log in, he should have credentials (username and password) with him. The credentials can be obtained after completing the registration process.
One may also ask,
If the user does not enter the fields and tries to click on the login button, the page notifies him about the required fields. It gives a message as shown in the below image. If the user enters the wrong credentials, the error message is displayed in red color as shown below.
In addition,
The JWT authentication service is used to login and logout of the application, to login it posts the users credentials to the api and checks the response for a JWT token, if there is one it means authentication was successful so the user details are added to local storage and the token saved to the AuthenticationService.token property.