Objective
The Objective of this application is to understand Angular Forms, Authentication & Security, Routing & Guards
Prerequisites
- Fork this boilerplate repository
- Clone the boilerplate repository and cd into it
- Install dependencies
npm install - Run the backend
npm run servewhich shall run on port:3000 - Run the frontend
npm run startwhich shall run on port:4200
Know your server
On running npm run serve, following apis would be available for your use -
- To authenticate user - POST - http://localhost:3000/auth/v1 - expecting data - { username, password }
- To check if user is authenticated - POST - http://localhost:3000/auth/v1/isAuthenticated - expecting header - { 'Authorization',
Bearer ${token}} - To get notes - GET - http://localhost:3000/api/v1/notes - expecting header - { 'Authorization',
Bearer ${token}} - To add a note - POST - http://localhost:3000/api/v1/notes - expecting header - { 'Authorization',
Bearer ${token}} and data - { note }
Assignment:
- Keep should use Material Design for it's UI
- User shall be shown a login form
- After authentication, user is able to see all the notes on the page loaded from server as Cards
- User is be able to create and persist notes on server
Instructions:
- You are expected to use
Noteclass for Note model AppModuleshall be the root module- Application to have two routes -
a.dashboardmapped toDashboardComponent
b.loginmapped toLoginComponent
dashboardbeing the default route AppComponentas the bootstrapping component - which displays theHeaderComponentand one other component based on the requested routeHeaderComponentto use Material Toolbar with text contentKeepLoginComponent
6.1. is expected to use Angular Reactive Forms with two form controlsusernameandpasswordwith classesusernameandpasswordrespectively and a button with textSubmitto submit the form
6.2. is expected to have an element with class nameerror-messageto display any server error messages
6.3. to have aloginSubmit()method called when form is submitted which shall validate the user credentials with server, if validation is successful, user is redirected todashboardand his token is saved in local storageDashboardComponentto contain the same Expansion Panel and the Notes Collection fromAppComponentimplemented inKeep Level 1CanActivateRouteGuardto protect dashboard route, redirect unauthenticated users to login route and return the authenticated status as true or false for the user fromcanActivatemethodAuthenticationServicetalks to the server for user authentication and shall include methods -
9.1authenticateUser()to get the user authenticated - accepts { username, password } and returns server response
9.2setBearerToken()to save user token in local storage with keybearerToken- accepts the token string
9.3getBearerToken()to fetch user token from local storage
9.4isUserAuthenticated()to validate authenticity of a user - accepts the token string and returns Promise of authenticated status of userNotesServicetalks to the server to fetch/persist data and shall include methods -
10.1getNotes()to fetch the notes collection
10.2addNote()to persist a note to serverRouterServiceto navigate user to available routes -
11.1routeToDashboard()to navigate to dashboard route
11.2routeToLogin()to navigate to login route- Ensure following commands succeed in your local machine before submitting your code for Preliminary automated review as described next -
npm install npm run build npm run lint - Ensure unit test cases pass -
npm run test - Ensure e2e test cases pass -
npm run serve(backend shall be running before executing e2e test cases)
npm run e2e
Submitting your solution for preliminary automated review
- Open
https://hobbes-cts.stackroute.in/#/and login into the platform - Under
Assignment repositoryselectangular-keep-level-2-assignment, and branchmaster - Under
Your solution repositoryselect your own repository and branch - Press
Submit - Press
click herefor the feedback - Evaluation will take around 5 mins to complete after which you need to refresh your browser and get the updated status
- Watch out for your total score and detailed status on each test and eslint errors in the coloured blocks on the screen
- Fix failing test cases as well as eslint errors and re-submit your solution (you may skip any eslint errors reported in the provided spec files)
MENTORS TO BEGIN REVIEW YOUR WORK ONLY AFTER ->
-
You add the respective Mentor as a Reporter/Master into your Assignment Repository
-
You have checked your Assignment on the Automated Evaluation Tool - Hobbes (Check for necessary steps in your Boilerplate - README.md file. ) and got the required score - Check with your mentor about the Score you must achieve before it is accepted for Manual Submission.
-
Intimate your Mentor on Slack and/or Send an Email to learner.support@stackroute.in - with your Git URL - Once you are done working and are ready for final submission.