GTBitsOfGood / bog-vms

Official Repository for the Bits of Good Volunteer Management System!
MIT License
4 stars 2 forks source link

User Creation and Login #46

Open tonyz0909 opened 4 years ago

tonyz0909 commented 4 years ago

As a user, I want to create my account and login using that account:

jazeved0 commented 4 years ago

Added/modified the necessary routes for basic user login/registration via email/password. Related to #50 and implemented in https://github.com/GTBitsOfGood/bog-vms/commit/b2c442ac66d152aa08bd3b3f92d1fd227a4b1fb5.

Added/Revamped Routes

POST /api/register/begin

First stage in registration process (first page for user registration). Only used to give email/password. Requires form data sent in:

password: 12345678
bio.email: john.doe@gatech.edu

Validates password length (> 8) and email structure. Validates email being unique before continuing.

Status Codes

POST /api/register/finish

Second/last stage in registration process (for user registration). Used to actually perform registration/create new document in database. Requires form data sent in:

bio.email:john.doe@gatech.edu
password: 12345678
bio.first_name: John
bio.last_name: Doe
bio.date_of_birth: 2020-03-08T22:11:55+0000
bio.street_address: 10 Lane St.
bio.city: Atlanta
bio.state: GA
bio.zip_code: 35363
bio.phone_number: 5035041932

Same validations as /api/register/begin, with the addition of: DOB must be ISO 8601, state must be alphabetical, zipcode must be numeric and 5 characters long, with no symbols. In addition, all other fields must exist except for skills_interests. Accepts same schema format as user document. Strips out all other fields other than the above and those in skills_interests before sending the user data to MongoDB to prevent injection.

Status Codes

POST /auth/login

Note that this URL is not under /api. Mostly implemented already; uses passport to implement cookie-based authentication (tied to session cookie). Used with logging in existing users via email//password. Note that the route uses username instead of email as the param key.

username: john.doe.4@gatech.edu
password: 12345678

Status Codes

GET /auth/logout

Already implemented; used to clear cookie/log out. Afterwards, user cannot access restricted routes if authentication is enabled until they sign back in.