Browse Source

fixed adminCreator.js

master
arnaucode 6 years ago
parent
commit
abf4257409
5 changed files with 14 additions and 16 deletions
  1. +0
    -3
      adminConfig.js
  2. +9
    -7
      adminCreator.js
  3. +3
    -3
      controllers/adminController.js
  4. +0
    -1
      controllers/userController.js
  5. +2
    -2
      server.js

+ 0
- 3
adminConfig.js

@ -1,3 +0,0 @@
module.exports = {
'passwordHash': 'Bzij4hEeEUpmXTWyS+X0LR+YcA8WFjP2P7qhW0sxA6s='/*password raw: adminPassword*/
};

+ 9
- 7
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);

+ 3
- 3
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

+ 0
- 1
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')

+ 2
- 2
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

Loading…
Cancel
Save