Bootcamp
Search…
3.POCE.6: Bird Watching Users

Base

Begin by making a branch 3-poce-5 to record the state of your code in the Bird Watching repo from 3.POCE.5. Start 3.POCE.6 by modifying the main branch after saving your previous code in the 3-poce-5 branch.
Implement the basic user login described in 3.6.2: User Auth.
When the user logs in, also set their user ID in a cookie.
1
response.cookie('userId', user.id);
Copied!

Create Users Table

1
CREATE TABLE users (id SERIAL PRIMARY KEY, email TEXT, password TEXT);
Copied!

Routes Reference

URL Path
Method
Purpose
/signup
GET
Render a form that will sign up a user.
/signup
POST
Accept a POST request to create a user.
/login
GET
Render a form that will log a user in.
/login
POST
Accept a POST request to log a user in.
/logout
DELETE
Log a user out. Get rid of their cookie.

User Notes

Alter the notes table so that a note is created by a logged-in user. When we accept a POST request to create a note use the user ID in the request cookie to associate the new note with the logged-in user.

Routes Reference

URL Path
Method
Purpose
/note
POST
Accept a POST request to create a new sighting.

Comfortable

User Name in Notes List

List the user name as part of the list of notes.

User Pages

Use EJS templates to create a unique page for each user with a list of all of that user's notes.
URL Path
Method
Purpose
/users/:id
GET
A list of all notes made by this user.

More Comfortable

Note Editing with Permissions

Implement editing and only allow the owner of the note to edit or delete it.

Reference solution

Click here to see the reference solution for this post class.