Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added login/signup page with basic functionality #27

Merged
merged 4 commits into from
Oct 16, 2021

Conversation

Raghuboi
Copy link
Contributor

  • login/signup page with basic functionality, query the database to register/authenticate a user

  • password hashing with bcrypt

  • currently there is no validation for email and password in the sign up form, it just inserts the user into the db as long as the password and confirm password fields match

  • will have to create sessions in the future, add form validation and send authentication links to emails

- login/signup page with basic functionality, query the database to register/authenticate a user

- password hashing with bcrypt

- currently there is no validation for email and password in the sign up form, it just inserts the user into the db as long as the password and confirm password fields match

- will have to create sessions in the future, add form validation and send authentication links to emails
export async function query(q, values) {
try {
const results = await pool.query(q, values)
await pool.end()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually don't want to ever close this pool. It should always be available for the lifecycle of the server.

@@ -0,0 +1,21 @@
require('dotenv').config(); //Load from the .env file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is loaded from the new server.js file, we don't need this anymore.

@@ -0,0 +1,21 @@
require('dotenv').config(); //Load from the .env file
const mysql = require('mysql2');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe import mysql2/promise so we can use async/await with the pools/queries

try {
const results = await query(`
SELECT password FROM users WHERE email = ?
`, email)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prepared Statements have to pass in their fields in an array, so you'd have to wrap email in an array.

[email]

@Raghuboi Raghuboi requested a review from xTrig October 15, 2021 23:16
- send validation link to email
*/

const hashedPW = await bcrypt.hash(password, 10)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The salt rounds should probably be a system constant somewhere, in case we decide to change it later for some reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added now

@xTrig xTrig merged commit bc7518b into UWCodeForce:main Oct 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants