-
Notifications
You must be signed in to change notification settings - Fork 11
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
Conversation
- 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
web/utils/query.js
Outdated
export async function query(q, values) { | ||
try { | ||
const results = await pool.query(q, values) | ||
await pool.end() |
There was a problem hiding this comment.
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.
web/utils/query.js
Outdated
@@ -0,0 +1,21 @@ | |||
require('dotenv').config(); //Load from the .env file |
There was a problem hiding this comment.
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.
web/utils/query.js
Outdated
@@ -0,0 +1,21 @@ | |||
require('dotenv').config(); //Load from the .env file | |||
const mysql = require('mysql2'); |
There was a problem hiding this comment.
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
web/pages/api/signin.js
Outdated
try { | ||
const results = await query(` | ||
SELECT password FROM users WHERE email = ? | ||
`, email) |
There was a problem hiding this comment.
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]
web/pages/api/signup.js
Outdated
- send validation link to email | ||
*/ | ||
|
||
const hashedPW = await bcrypt.hash(password, 10) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added now
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