- Walk through the process of creating a user
- Create a user
- Explain what Authentication is
- Walk through the process of authenticating (logging in) a user
- Explain how to use
.env - Login a user
- https://github.com/rogerwschmidt/auth-example-backendh <- I know about the typo
- Install application
- Start server
psql auth_example_dev -c 'SELECT * FROM users;'
- What path does the code take when running the following command
http POST :3000/users username="student" password="student"
- What is in the body of the response?
- What gets stored in the database while creating a user?
- What happens if you try to create a user with a duplicate user name?
- What new libraries are used that you have not seen before?
- What are those libraries doing?
- Switch branches
git checkout user_model_create_removed - Complete the model so that a user can be created.
- The following command
http POST :3000/users username="student" password="student"
Should:
- Make sure that the user does not exists in the database?
- Hash the password
- Return the new user without the hashed password
Make sure to commit your changes
- With your table, create a definition of what authentication is. Be prepared to share your definition.
- Why would Authentication be useful in a web application?
- On your
masterbranch - What path does the code take when running the following command
http POST :3000/auth/toke username="student" password="student"
- What is in the body of the response?
- What happens if the user does not exists?
- What happens when when the password does match?
- What happens when when the password does not match?
- What is
process.env.SECRETused for? - What new libraries are used that you have not seen before?
- What are those libraries doing?
- What is .env is used for?
- What package loads the contents of the
.envintoprocess.env?
- Switch branches
git checkout auth_model_login_removed - Complete the controller and model for
auth - The following command
http POST :3000/auth/token username="student" password="student"
Should
- Return an appropriate error
- Return a token when authentication is successful
Commit all your changes
Hashing algorithm
npm install --python=python2.7 bcrypt-as-promised
Token creation and validation library
npm instal jsonwebtoken
Environement management tool
npm install --save-dev dotenv