Best Tutorial for angular 2 | How to Set up Authentication and authorization In Angular 2

160 views
Skip to first unread message

Pahadi Rocks

unread,
Jun 17, 2016, 11:26:19 PM6/17/16
to AngularJS

In a real scenario, we usually delegate all the heavy lifting on an authentication service that wraps all the necessary tools for handling user login, logout, and sometimes authentication for granting access to protected areas of our application.

we will create a simplified version of such service and will put it in charge of handling user login along with the component we just created in the previous section. This service will also manage auth token persistence and provide methods to check if the user has access granted to secure pages.

Before jumping into the code, let’s summarize the minimum requirements this service must fulfil:

  • We need its API to expose a method to handle user login
  • User logout must be handled as well by a public method in this API
  • A third method or property should inform if the user is logged in or not so they can proceed to secured pages
  • Having an observable property informing of the current state of the active user for authentication will become handy to make the overall UI more reactive

read full tutorial

Reply all
Reply to author
Forward
0 new messages