Challenge: Implement Authorization

Complete the challenge of implementing authorization in an Angular application.

Problem statement

Suppose there is an e-commerce web application. In your application, there are the following roles:

  1. User

  2. Admin

  3. Anonymous (a user who is not logged in)

Requirements

In the initial code setup provided below, you are required to implement the authorization in the application with the following constraints:

  1. If the logged in person’s role is “user,” then they can view and buy the products.

  2. If the logged in person’s role is “admin,” then they can create, view, delete, and update the price of products.

  3. If the person is not logged in, then their role is “anonymous,” and they can only view the products.

Expected output

The output should be the following:

User

If the role is “user” and the person selects the product from the “Product List,” they can see the “Buy Now” button under “Product Details,” as shown below:

Get hands-on with 1400+ tech skills courses.