From a25ac4bc7159b5cb55de272945d5749d781dc0d3 Mon Sep 17 00:00:00 2001 From: Brad Dickason Date: Fri, 26 May 2017 23:15:29 -0700 Subject: [PATCH 1/2] Added repository field to package.json to prevent warnings during npm install --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index da57dbf..f8d4991 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,10 @@ }, "author": "Stephen Stafford", "license": "ISC", + "repository": { + "type": "git", + "url": "https://github.com/srstafford1996/chicken-server" + }, "dependencies": { "bcrypt": "^1.0.2", "body-parser": "^1.17.1", From b92bea9b6091b2ac531fb780b7e21e4017b115f9 Mon Sep 17 00:00:00 2001 From: Brad Dickason Date: Sat, 27 May 2017 22:53:21 -0700 Subject: [PATCH 2/2] Switch to bcryptjs to deploy on machines with g++ <4.9 --- package.json | 2 +- server/api/users/controller.js | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index f8d4991..68ff772 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "url": "https://github.com/srstafford1996/chicken-server" }, "dependencies": { - "bcrypt": "^1.0.2", + "bcryptjs": "^2.4.3", "body-parser": "^1.17.1", "express": "^4.15.2", "mysql": "^2.13.0", diff --git a/server/api/users/controller.js b/server/api/users/controller.js index b2e6535..b2ff085 100644 --- a/server/api/users/controller.js +++ b/server/api/users/controller.js @@ -1,5 +1,5 @@ //Node modules -const bcrypt = require('bcrypt') +const bcrypt = require('bcryptjs') const uuid = require('uuid/v4') const mysql = require('mysql') @@ -24,10 +24,10 @@ class UsersController { const displayName = mysql.format(options.displayName) const existingUserCheck = `SELECT accountName, email, displayName ` + - `FROM ${_USERTABLE} ` + + `FROM ${_USERTABLE} ` + `WHERE (accountName = '${accountName}' OR email ='${email}' OR displayName = '${displayName}')` - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { this.$store.getDatabaseConnection().then((connection) => { connection.query(existingUserCheck, (err, results) => { //If this query returned results then there is a user with a matching field @@ -39,10 +39,10 @@ class UsersController { if(mysql.format(user.accountName) == accountName) { sharedField = 'account name' - } + } else if(mysql.format(user.email) == email) { sharedField = 'email address' - } + } else if(mysql.format(user.displayName) == displayName) { sharedField = 'display name' } @@ -60,7 +60,7 @@ class UsersController { } hashedPass = mysql.format(hashedPass) - const insertQuery = `INSERT INTO ${_USERTABLE} ` + + const insertQuery = `INSERT INTO ${_USERTABLE} ` + `(\`accountName\`, \`hashedPass\`, \`email\`, \`displayName\`) ` + `VALUES ('${accountName}', '${hashedPass}', '${email}', '${displayName}')` @@ -68,7 +68,7 @@ class UsersController { connection.release() if(err) { reject(err) - return; + return; } //Build new session @@ -116,7 +116,7 @@ class UsersController { return; }) }) - }, err => reject(err)) + }, err => reject(err)) }) } @@ -175,4 +175,4 @@ class UsersController { } } -module.exports = UsersController \ No newline at end of file +module.exports = UsersController