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 the return
statement of the authenticator module. Now modify the login
method to check whether the server returns a false
for the login call. In case of authentication failure, set the showAuthenticationFailed
flag to false
and do not proceed any further...