Web Programming
Todo SPA (Sessions)
The objective of this exercise is to extend the
todo single-page application so that users can login to access their individual todos.
Tasks
-
Add
setUser and getUser methods to the store object which are used to store and retrieve an authenticated user.
-
Add a
postUser method to the service object which sends an AJAX request to register a new user, and use the stored user to send an authorization header with each other request.
-
Implement the
Login component:
- The template contains a form that allows a user to enter their name and password.
- The login event handler fetches the todos of the user and saves the user and their todos in the store.
- The register event handler posts the user and saves the user and an empty todo list in the store.
Display appropriate error messages, if the credentails are invalid or the user already exists.
-
In the
main module, register the Login with the router and use it as the initial component.
-
(Optional) Implement the
Logout component that clears the store and displays a confirmation message, and include a link in the application to navigate to the component.