From 7888529c17326770caa03300a7721baac1b6b743 Mon Sep 17 00:00:00 2001 From: Matthew Strapp Date: Fri, 30 Apr 2021 09:40:43 -0500 Subject: Act on gag order with html --- csci4131/hw7/dbio.js | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'csci4131/hw7/dbio.js') diff --git a/csci4131/hw7/dbio.js b/csci4131/hw7/dbio.js index 302334b..dcc7386 100644 --- a/csci4131/hw7/dbio.js +++ b/csci4131/hw7/dbio.js @@ -1,21 +1,35 @@ var mysql = require("mysql"); var bcrypt = require("bcrypt"); +var fs = require("fs"); +var xml2js = require("xml2js"); +var parser = new xml2js.Parser(); +var conInfo; +var connection; -var connection = mysql.createConnection({ - host: "cse-mysql-classes-01.cse.umn.edu", - user: "C4131S21U83", - password: "6919", - database: "C4131S21U83", - port: 3306 -}); +fs.readFile(__dirname + '/dbconfig.xml', function (err, data) { + if (err) throw err; + parser.parseString(data, function (err, result) { + if (err) throw err; + conInfo = result; + }); + connection = mysql.createConnection({ + host: conInfo.dbconfig.host[0], + user: conInfo.dbconfig.user[0], + password: conInfo.dbconfig.password[0], + database: conInfo.dbconfig.database[0], + port: conInfo.dbconfig.port[0] + }); -connection.connect(function(err) { - if (err) { - throw err; - }; - console.log("Connected to MYSQL database!"); + connection.connect(function (err) { + if (err) { + throw err; + }; + console.log("Connected to MYSQL database!"); + }); }); + + function passcheck(user,pass) { return new Promise(function(resolve, reject) { connection.query('SELECT * FROM tbl_accounts', function(err, rows, fields) { -- cgit v1.2.3