Project Part 3
In this part of the project, you will be adding user account functionality to our website. Users need to be able to sign up, log in, and log out, so you will be adding this functionality. Additionally, you will be getting rid of the username field from your post and comment forms, and using the logged in username.
From a user’s perspective, you aren’t adding too much in this part. However, these functions are at the core of the front-end and back-end working together.
The challenge of authentication has a very large solution space. I’m constraining it for the purposes of this project. I’ll be installing Passport.js and the `passport-local` strategy. Use these and store any persistent information you need in Couchbase. Feel free to change the data model as you need for this part of the project.
Requirements
Please implement the following three pages and one set of changes in your repo. Similar to the last project, if a form is submitted with an error, it is expected that a message be displayed and the user stay on the same page.
Registration Page (/register.html)
This page will allow users to create an account. It should include a form that lets the user enter a username, password to be used, and a password verification field. It should not allow duplicate usernames, empty usernames, or empty passwords, producing an error in these cases. If it is successful, the user should be taken to the login page.
Login Page (/login.html)
This page will allow a user to authenticate themselves to the website. There should be a form that lets the user enter their username and password. On a failed login attempt, the user should stay on the same page and have an error indicating that the login failed without indicating why. On successful login, the user should be redirected to their user page.
Logout Page (/logout.html)
This page should thank the user for visiting, then redirect to the landing page after two seconds, requiring no interaction. As a consequence, the user should not be logged in anymore.
Changes
Remove the username field in forms that allow the user to make posts or comments. Instead infer the user’s username from their login. If the user is not logged in, replace the form with a link to the login page, and an explanation that you must be logged in to post or comment.
Restrictions
Please do not use any outside JavaScript libraries, except the ones I install in your npm project. Also, please conform to the academic integrity policy of the course.
Submitting
To submit the project, create a new release in GitLab with name like “project3-24-08-2020” (instructions available at https://docs.gitlab.com/ee/user/project/releases/index.html#create-a-release) and email me that you would like it graded. You may do this up to two times a week. I will do my best to get back to you with a graded rubric by the end of the next workday. This project, like all other projects, is due Friday, December 4, 2020 at noon. However, I recommend that you finish this within the first few weeks of its availability.
Rubric
| Points | Requirement | Comment |
| Registration Page Requirements | ||
| __/1 | Registration errors behave correctly | |
| __/1 | New record(s) in database for user | |
| __/1 | Redirected to login page | |
| __/1 | Password field hidden | |
| __/1 | User page exists prior to login | |
| __/1 | Full happy path behavior of registration | |
| Login Page Requirements | ||
| __/1 | Login errors behave correctly | |
| __/1 | User redirected to homepage on login | |
| __/1 | Password field hidden | |
| __/3 | Password validation correct | |
| Logout Page Requirements | ||
| __/1 | Redirects user to landing page | |
| __/1 | Logs out logged in user | |
| __/1 | Handles not logged in user sanely | |
| Change Requirements | ||
| __/2 | Form behaves according to spec with no login | |
| __/3 | Form behaves according to spec with user logged in | |
| Documentation Requirements | ||
| __/1 | Project runs with `git pull`, `npm install`, `npm start`, and visiting `https://localhost:8888` in the browser | |
| __/4 | README.md explains what source files do and source files contain meaningful comments | |
| __/25 | __/25 * 7 = ____ |