In this user story, we will give the users the ability to be able to log out of the application. To implement the logout feature, we will:
Add a method to the
authenticator
module to send a logout request to the server and reload the applicationUpdate the view to display the logout link
Let's start by adding a method to the authenticator
module. We will name this method logout
. This method should send a logout request to the server, clear the token stored in the session, and reload the application. The server invalidates the token on the logout request. Reloading the application will clear it from any data stored about the user. Add this method to the return
statement of the authenticator
module. Our implementation looks similar to this:
/* logout out of the application */ var logout = function() { server.logout(authenticationToken()); sessionStorage.clear(); document.location.reload(true); };
Now we can update the view and add the logout link. We will modify...