Handling the authentication error

This user story is about displaying a message to the user if the login fails based on the username and password that the user has provided. To implement this user story, we will take the following steps:

  • Add a flag to the authenticator module to show or hide the authentication error
  • Modify the login method of the authenticator module to check for the authentication error
  • Update the view to add an alert box with the authentication error

Let's get started by opening the authenticator module and adding an observable that will serve as a flag to show or hide the authentication error alert box:

/* flag to show authentication failed message */
var showAuthenticationFailed = ko.observable(false);

Add the preceding flag to ...

Get KnockoutJS by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.