Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Run ng generate component component-name
to generate a new component. You can also use ng generate directive/pipe/service/class/module
.
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the -prod
flag for a production build.
Run ng test
to execute the unit tests via Karma.
Run ng e2e
to execute the end-to-end tests via Protractor.
Before running the tests make sure you are serving the app via ng serve
.
To get more help on the Angular CLI use ng help
or go check out the Angular CLI README.
- Complete the
onLoginSubmit
andonSignupSubmit
methods to makePOST
requests (sending the user's credentials) to theapi/users/authenticate
andapi/users
endpoints respectively - Provide a method in
auth.service.js
which saves the returned JWT in local storage - Create a
logout
method which removes the user's JWT from local storage - Provide buttons for Log In and Log Out in the home view and the toolbar
Step 1:
- Create a screen for login and signup
- Make a POST request with the user’s credentials
- Store the JWT that comes back in local storage
- Create a logout method which removes the token from local storage
- Provide buttons for Log In and Log Out in the home view and the toolbar
Step 2:
- Create an
isAuthenticated
method in theAuthService
which checks whether the user's JWT has expired (Hint: use angular2-jwt for this) - Conditionally hide and show the Log In and Log Out links based on whether the user's JWT is expired
Step 3:
- Use the payload from the JWT to generate a user profile
- Display the user's gravatar, username, and email, along with the full JWT payload in the Profile view
Step 4:
- Make an authenticated
GET
request to the/instructors
endpoint and display the returned resources in the Instructors view - Add a method called
isAdmin
toauth.service.js
and conditionally show and hide the Add Instructor button in the/instructor
view based on whether the user is authenticated and is an admin +* Make an authenticatedPOST
request to the/instructors
endpoint to create a new instructor and return to the Instructors route to dispaly the newly created resource
Step 5:
- Add
data { requiresLogin: true }
to the/profile
,/instructor
and/instructor/new
routes +* Make an authenticatedGET
request to the/instructors
endpoint and display the returned resources in the Instructors view - Add a method called
isAdmin
toauth.service.js
and conditionally show and hide the Add Instructor button in the/instructor
view based on whether the user is authenticated and is an admin