Ionic 2 Asynchronous Login

Creating an Asynchronous Login Screen in Ionic 2



·

If you add a login screen to your application, then there is a good chance that you will also implement some functionality that allows you to remember users who have logged in previously. It’s pretty annoying to have to enter in your credentials every time you use an application. Instead, it is preferable to send users who have already authenticated directly to the main application, and anyone who hasn’t should be sent to the login screen.

Checking if a user is authenticated usually requires making a call to a server, though, and this takes a small amount of time. We need to know how to gracefully handle the following sequence:

  • User opens application
  • An asynchronous call is made to some authentication service
  • If the user is logged in they are sent to the main application
  • If the user is logged out they are sent to the login page

In this video tutorial, we are going to walk through how to handle this process in Ionic 2 in such a way that the application does not feel like it is slow or frozen as it is making the authentication check.

Here’s the video:

What to watch next...