From c661302425835448b8063b5edfc85567c880edd2 Mon Sep 17 00:00:00 2001 From: Mark Tyers Date: Sun, 17 Mar 2019 12:17:44 +0000 Subject: [PATCH] deleted solutions --- exercises/07_forms_auth/modules/accounts.js | 28 +++++-------------- .../07_forms_auth/tests/accounts.spec.js | 0 exercises/07_forms_auth/tests/index.spec.js | 0 3 files changed, 7 insertions(+), 21 deletions(-) create mode 100644 exercises/07_forms_auth/tests/accounts.spec.js create mode 100644 exercises/07_forms_auth/tests/index.spec.js diff --git a/exercises/07_forms_auth/modules/accounts.js b/exercises/07_forms_auth/modules/accounts.js index 8beda1f..f944b6b 100644 --- a/exercises/07_forms_auth/modules/accounts.js +++ b/exercises/07_forms_auth/modules/accounts.js @@ -7,12 +7,12 @@ 'use strict' -const sqlite = require('sqlite-async') -const bcrypt = require('bcrypt-promise') +var sqlite = require('sqlite-async'); +let bcrypt = require('bcrypt-promise'); /** * This is a generic function that opens the database, executes a query, - * closes the database connection and returns the data. + * closes the database connection and returns the data. * @param {String} query - The SQL statement to execute. * @returns {Object} - the date returned by the query. */ @@ -42,6 +42,8 @@ module.exports.checkCredentials = async(username, password)=> { } } + + /* ----------------------------- STUB FUNCTIONS ----------------------------- */ /** @@ -52,14 +54,7 @@ module.exports.checkCredentials = async(username, password)=> { * @throws {Error} - throws an error if the username already exists. */ async function checkNoDuplicateUsername (username) { - try { - const sql = `SELECT count(id) AS count FROM users WHERE user="${username}";` - const num_records = await runSQL (sql) - if(num_records.count) throw new Error ('Username already Exists!') - return true - } catch (err) { - throw err - } + return true } /** @@ -81,14 +76,5 @@ async function saveImage(path, mimetype) { * @throws {Error} - throws an error if the new user account has been created. */ module.exports.addUser = async(username, password) => { - try { - await checkNoDuplicateUsername(username) - const saltRounds = 10 - password = await bcrypt.hash(password, saltRounds) - const sql = `INSERT INTO users(user, pass) VALUES("${username}", "${password}")` - await runSQL(sql) - return true - } catch(err) { - throw err - } + return true; } \ No newline at end of file diff --git a/exercises/07_forms_auth/tests/accounts.spec.js b/exercises/07_forms_auth/tests/accounts.spec.js new file mode 100644 index 0000000..e69de29 diff --git a/exercises/07_forms_auth/tests/index.spec.js b/exercises/07_forms_auth/tests/index.spec.js new file mode 100644 index 0000000..e69de29