Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
4e868ed
Initial commit.
jcelder Nov 27, 2017
ff26a45
Added method-override dependency and eslint dev dependencies.
jcelder Nov 27, 2017
11cd8f0
Added method-override to fix missing dependency issue.
jcelder Nov 29, 2017
f79e90b
Added express-session and bcrypt.
jcelder Nov 29, 2017
c5c8538
Added connect-pg-simple.
jcelder Nov 29, 2017
70acf5d
Copied required project specs from https://github.com/LearnersGuild/c…
jcelder Nov 29, 2017
bc30b71
Initial commit.
jcelder Nov 29, 2017
f29c0b8
Completed basic layout of sign up form.
jcelder Nov 29, 2017
1a7d6ec
Completed basic layout of log in form.
jcelder Nov 29, 2017
632be7a
Updated completed specs.
jcelder Nov 29, 2017
b366b4b
Added basic routes for '/signup' and 'login'.
jcelder Nov 29, 2017
a89ccda
Added authentication routes.
jcelder Nov 29, 2017
a7a8a3d
Fixed ESlint errors.
jcelder Nov 29, 2017
8d0b982
Added users table.
jcelder Nov 29, 2017
6477e67
Initial commit.
jcelder Nov 29, 2017
56f1273
Changed 'password' column to 'encrypted_password'.
jcelder Nov 29, 2017
1dfd2d2
Added createUser() query.
jcelder Nov 29, 2017
1752998
Abstracted createUser from db/authentication.js
jcelder Nov 29, 2017
9f3be67
Add create user functionality to '/login' route.
jcelder Nov 29, 2017
adb8897
Add query for getUserByEmail().
jcelder Nov 29, 2017
d119db7
Abstract getUserByEmail from './db/authentication.js'.
jcelder Nov 29, 2017
6d49df8
Add authentication logic for '/login' route.
jcelder Nov 29, 2017
8348e8a
Add primary key constraint to contacts table.
jcelder Nov 29, 2017
30c248b
Refactor getUserByEmail() query.
jcelder Nov 29, 2017
83d02ab
Fix action target on form to point to '/login'.
jcelder Nov 29, 2017
a3bccf0
Complete basic login functionality for '/login'.
jcelder Nov 29, 2017
ef1eba5
Add encryption to user password on '/signup' route.
jcelder Nov 29, 2017
9a74c56
Fix async errors.
jcelder Nov 29, 2017
c1c3fd6
Change user.password to user.encrypted_password on the input object o…
jcelder Nov 29, 2017
f9bea96
Add bcrypt compare to '/login' route.
jcelder Nov 30, 2017
0229a84
Merge branch 'master' into auth
jcelder Nov 30, 2017
2e23fed
Updated completed specs.
jcelder Nov 30, 2017
6e8ae63
Add error message display to user when credentials are invalid
tls11 Nov 30, 2017
a5da54b
Update complete specifications
tls11 Nov 30, 2017
4552347
Add express session
tls11 Nov 30, 2017
7ce09ca
Fix ESlint errors.
jcelder Nov 30, 2017
71021f3
Reassign req.session.sid to logged in user's email.
jcelder Nov 30, 2017
c2501ff
Redirect user to '/login' or '/' depending upon authentication status.
jcelder Nov 30, 2017
df71586
Fix ESlint errors.
jcelder Nov 30, 2017
dec78e6
Fix ESlint error.
jcelder Nov 30, 2017
352d945
Update completed specs.
jcelder Nov 30, 2017
0572725
Add 'session' table for connect-pg-simple.
jcelder Nov 30, 2017
e09a1ab
Change req.session.id to req.session.email for clarity.
jcelder Nov 30, 2017
8f2327b
Change req.session.sid to req.session.email to reflect information be…
jcelder Nov 30, 2017
770c8ac
Require and implement 'connect-pg-simple'.
jcelder Nov 30, 2017
6110d95
Update completed specs.
jcelder Nov 30, 2017
c3a9552
Add roles to 'roles' table.
jcelder Nov 30, 2017
1689533
Add 'roles' table.
jcelder Nov 30, 2017
04948fa
Add 'load_schema' command to insert roles into 'roles' table.
jcelder Nov 30, 2017
3da7830
Add load_roles to db:reset.
jcelder Nov 30, 2017
3022a44
Chain query to add role to database by 'user.id'.
jcelder Nov 30, 2017
61cf47b
Update completed specs.
jcelder Nov 30, 2017
0591559
Update getUserByEmail query to return roles(in an array) along with p…
jcelder Nov 30, 2017
4934ec3
Update '/login' route to add roles(array) to req.session.
jcelder Nov 30, 2017
b66fc49
Add page for status 403.
jcelder Nov 30, 2017
bf49737
Add authorization to '/new' and '/:contactId' routes.
jcelder Nov 30, 2017
31b3920
Abstract authorization from routes into separate 'checkRoles' middlew…
jcelder Dec 1, 2017
dc7736d
Move checkRoles() to 'src/server'middlewares.js'.
jcelder Dec 1, 2017
b8dcec7
Add checkRoles() middleware to '/new' and '/:contactId' routes.
jcelder Dec 1, 2017
d5bfcbe
Add sending status code 403 to a failed authorization check in checkR…
jcelder Dec 1, 2017
25611f3
Update completed specs.
jcelder Dec 1, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,25 @@
1. Load your database with the schema: `npm run load_schema`
1. Install your dependencies: `npm install`
1. Run the server: `nodemon`

## Specifications

- Authentication
- [x] Create a signup page with a form (links to the login page)
- [x] Create a login page with a form (links to the signup page)
- [x] Redirect users who are not logged in to the login page (Make sure not logged in users can't see any of the pages or data other than the login and signup pages)
- [x] Create a user table in the database
- [x] When a user signs up, a new user row is created in the user table
- [x] When a user logs in, their username and password are validated in the user table. If the username/password combo doesn't exist or is invalid, the user receives an error.
- [x] Passwords are encrypted with `bcrypt`
- [x] [express-session][express-session] is used to store sessions on the server side. Notice the differences between storing sessions on client side(using [cookie-session][cookie-session] vs storing sessions on the server side(using `express-session`).
- Authorization
- [x] A user should have a `role` associated to it. The values are `admin` or `regular`.
- [x] Only a user with an `admin` role should be able to create a new contact. If the logged in user is not an `admin`, going to the route `/contacts/new` should return a status code 403.
- [x] Only a user with an `admin` role should be able to delete a contact. If the logged in user is not an `admin`, going to the route `/contacts/delete/:contactId` should return a status code 403. The delete links on the page should not be shown if the logged in user is not an `admin`.

## Stretch Specs

- [x] If you use [express-session], use a persistent session store https://www.npmjs.com/package/connect-pg-simple to store the sessions (instead of the default in memory store that `express-session` uses)
- [x] A user should be able to have more than one role. For example, a user can have roles `reporter`, and `editor`, which would give them access to the resources that are available to both those roles.
- [ ] Add [schema migrations](https://en.wikipedia.org/wiki/Schema_migration) for your database using https://github.com/theoephraim/node-pg-migrate
Loading