Assignment - User Authentication
Assignment - User Authentication
Instructions
In this assignment you will extend to verify an Admin and grant appropriate privileges to
an Admin. In addition, you will allow only a member to update his/her information. Neither
another member, nor an Admin can edit this information.
You will now create the members Schema and model to support the document:
"membername": "admin",
"password": "xxxxxxxxxxxxxxxxxxxxxxxxx",
“YOB”: 1990,
“isAdmin”: true
}
Password must be hashed by using bcrypt module.
comments: [commentSchema]
1
brand:{type: mongoose.Schema.Types.ObjectId, ref: "Brands", require: true},
},{timestamps: true}
membername{ type: String, require: true}, password{ type: String, require: true}, isAdmin:
{type: Boolean, default: false}},{ timestamps: true, });
Assignment Overview
At the end of this assignment, you would have completed the following:
Using Mongoose population to populate information into the watch document from the
referenced brand document.
Allow only an Admin to perform GET, POST, PUT and DELETE operations in private
routes.
Allow an Admin to be able to GET all the registered members' information from the
database.
2
Allow a member to edit his/her information. They should be restricted from performing
such operations only on his/her own account. No member or even the Admin can edit
or delete the information by other members.
Members can send their comments to watches. Only one comment on an watch.
Assignment Requirements
This assignment is divided into four tasks as detailed below; all tasks should build
with their UI:
Task 1
In this task you will implement the public routes which all the users can access, including:
The index route that shows all of watches, the data will include name, image and
brandName.
Outstanding design for the true value (Automatic property) of the watch.
Task 2
In this task you will update all the routes to ensure that only the Admin can perform GET,
POST, PUT and DELETE operations. Update the code for all the routers to support this.
These operations should be supported for the following endpoints:
GET, POST, PUT and DELETE operations on /brands and / brands /: brandId
3
GET, POST, PUT and DELETE operations on /watches and / watches /: watchId
Task 3
In this task you will implement the feedback feature that includes the posting comment and
rating function. Only members can feddback. Each member can only feedback one watch
once.
Task 4
In this task you will now activate the /accounts endpoint. When an Admin sends a GET
request to /accounts you will return the list of all the members. Ordinary members are
forbidden from performing this operation.