From abf4257409eadae96e1d51087db5660cbf111d7e Mon Sep 17 00:00:00 2001 From: arnaucode Date: Mon, 22 Jan 2018 19:14:49 +0100 Subject: [PATCH] fixed adminCreator.js --- adminConfig.js | 3 --- adminCreator.js | 16 +++++++++------- controllers/adminController.js | 6 +++--- controllers/userController.js | 1 - server.js | 4 ++-- 5 files changed, 14 insertions(+), 16 deletions(-) delete mode 100755 adminConfig.js diff --git a/adminConfig.js b/adminConfig.js deleted file mode 100755 index 2aab7c1..0000000 --- a/adminConfig.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - 'passwordHash': 'Bzij4hEeEUpmXTWyS+X0LR+YcA8WFjP2P7qhW0sxA6s='/*password raw: adminPassword*/ -}; diff --git a/adminCreator.js b/adminCreator.js index 81eb978..3f8e9ae 100644 --- a/adminCreator.js +++ b/adminCreator.js @@ -2,31 +2,34 @@ var mongoose = require('mongoose'); var config = require('./config'); -var adminConfig = require('./adminConfig'); // get our config file +//var adminConfig = require('./adminConfig'); // get our config file mongoose.Promise = global.Promise; // Connection to DB mongoose.connect(config.database, function(err, res) { - if (err) throw err; + if (err) { + console.log(err); + }; console.log('Connected to Database'); }); - +var express = require("express"); +var app = express(); var adminMdl = require('./models/adminModel')(app, mongoose); var adminModel = mongoose.model('adminModel'); /* */ -var jwt = require('jsonwebtoken'); // used to create, sign, and verify tokens +/*var jwt = require('jsonwebtoken'); // used to create, sign, and verify tokens var express = require("express"); -var app = express(); var config = require('./config'); // get our config file app.set('superSecret', config.secret); // secret variable +var request = require('request');*/ var crypto = require('crypto'); /* */ -var request = require('request'); + var readlineSync = require('readline-sync'); @@ -84,4 +87,3 @@ admin.save(function(err, admin) { console.log("admin created correctly"); process.exit(0); }); -process.exit(0); diff --git a/controllers/adminController.js b/controllers/adminController.js index dcbb485..eeaa29b 100755 --- a/controllers/adminController.js +++ b/controllers/adminController.js @@ -8,7 +8,7 @@ var travelModel = mongoose.model('travelModel'); var travelCtrl = require('../controllers/travelController'); var config = require('../config'); -var adminConfig = require('../adminConfig'); // get our config file +//var adminConfig = require('../adminConfig'); // get our config file var pageSize = config.pageSize; /* */ @@ -25,7 +25,7 @@ var request = require('request'); //POST - Insert a new User in the DB -exports.signup = function(req, res) { +/*exports.signup = function(req, res) { var admin = new adminModel({ @@ -53,7 +53,7 @@ exports.signup = function(req, res) { exports.login(req, res); }); -}; +};*/ //POST - auth user diff --git a/controllers/userController.js b/controllers/userController.js index 8cfd313..8d34e67 100755 --- a/controllers/userController.js +++ b/controllers/userController.js @@ -576,7 +576,6 @@ exports.doUnfav = function(req, res) { }); }; exports.changePassword = function(req, res) { - console.log(req.body); userModel.findOne({ 'token': req.headers['x-access-token'], 'password': crypto.createHash('sha256').update(req.body.old).digest('base64') diff --git a/server.js b/server.js index 76f7c13..3ebc37e 100755 --- a/server.js +++ b/server.js @@ -77,8 +77,8 @@ apiRoutes.route('/travels/id/:travelid') apiRoutes.route('/admin/login') .post(adminCtrl.login); -apiRoutes.route('/admin/signup') - .post(adminCtrl.signup); +/*apiRoutes.route('/admin/signup') + .post(adminCtrl.signup);*/ // OJU AQUƏ TREC la verificaciĆ³ de token temporalment, per fer les proves des de l'app // route middleware to verify a token