CS356: Lab 3


Due: See Moodle for the due date and time

Goals:

·         Set up install postman and use to test your routes

·         Create a registration route to register new users. 

·        Create a login route to login registered users

Requirements:

0.    Make a copy of your existing workspace called lab3, which will contain a devconnector directory.

 

1.    Implement the book’s /aip/users/register/ route as described in video chapter 3: User Registration & Postman video. (20)

 

2.    Test at least the following: (30 – 10 points for each test).  You earn these points when I successfully test the code you submit.

·       Sunny1: Register a new user.  Must return something like:

Status 200

Data:

{

    "_id": "5bd0b2269d62c63494b32e92",

    "name": "registration2",

    "email": "reg2email",

    "password": "$2a$10$CjJB8FD49XYBAWLrfn8tYOD10Z2IKnKrHpfBNTa901f9B9WtcD6Hy",

    "date": "2018-10-24T17:55:50.782Z",

    "__v": 0

}

·       Rainy1: attempt registration of an email that already exists.  Must return Status 400 and “Email already exists” error.

·       Rainy2: send a request that does not contain the password field.  Must return Status 400 and “Password not supplied” error.  The server must not crash.

 

3.    Implement the book’s /aip/users/login/ route as described in video chapter 3: Email & Password Long and Creating the JWT videos. (20)

 

4.    Test at least the following: (30 – 10 points for each test).  You earn these points when I successfully test the code you submit.

·       Sunny1: login a previously registered user by passing the correct email and password.  Must return Status 200 and a JWT showing {“success”: true and “token”: “Bearer …”}.

·       Rainy1: attempt to login with an email that doesn’t exist.  Must return Status 400 and {credentials: “invalid credentials”} json.

·       Rainy2: attempt to login with a valid email, but wrong password.  Must return Status 400 and {credentials: “invalid credentials”} json

 

5.    Zip your lab2 directory and submit your zip file on moodle by clicking on the Lab2 assignment link.

Hints:

../demos/08formsRoutesAndPostman.zip  implements almost all of requirement 1 of the lab.

Caution: unzip it to a temp directory, so you do not overwrite your ongoing work.