From 971fd7ca41bb15a57a87b5aa9080cdf39e8cf826 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Thu, 4 Nov 2021 13:10:56 -0500 Subject: [PATCH] Implement MongoDB authentication --- backend/app.js | 6 ++++-- backend/config/db.js | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/app.js b/backend/app.js index ec954eb..2592846 100644 --- a/backend/app.js +++ b/backend/app.js @@ -13,8 +13,8 @@ const CoinGecko = require('coingecko-api'); //const RequestIP = require('@supercharge/request-ip'); var db = require('./config/db'); -mongoose.connect(db.url).then(() => { - console.log("connecting-- ", db); +mongoose.connect('mongodb://'+db.user+':'+db.password+'@'+db.server+'/'+db.database).then(() => { + console.log("connecting-- ", db.database); }).catch(() => { console.log("connection failed!"); }); @@ -128,6 +128,8 @@ var blockInterval = setInterval( function() { console.log(err); } console.log('Owner saved!'); + }).catch(() => { + console.log('Owner exists'); }); } }).catch((err) => { diff --git a/backend/config/db.js b/backend/config/db.js index 48c8b16..b9f4a66 100644 --- a/backend/config/db.js +++ b/backend/config/db.js @@ -1,3 +1,6 @@ module.exports = { - url : 'mongodb://localhost:27017/test' + server : 'localhost:27017', + user: 'zgo', + password: 'zcashrules', + database: 'zgo' }