solved several issues

parent 2ff46548
......@@ -7,7 +7,7 @@
const moment = require('moment');
//
//-----------------------------------------------------------------------------
// RedSys Javascript API
//
const cryptojs = require("crypto-js");
......@@ -28,7 +28,7 @@ function cipherMerchantKey(order, key) {
function encodeMerchantParams(object) {
// Base64 encoding of parameters
var merchantWordArray = cryptojs.enc.Utf8.parse(JSON.stringify(tpvdata));
var merchantWordArray = cryptojs.enc.Utf8.parse(JSON.stringify(object));
return merchantWordArray.toString(cryptojs.enc.Base64);
}
......@@ -43,6 +43,7 @@ function signMerchantParams(params, key) {
var signature = cryptojs.HmacSHA256(params, key);
return signature.toString(cryptojs.enc.Base64);
}
//-----------------------------------------------------------------------------
//
// TPV Controller
......
......@@ -324,7 +324,7 @@ module.exports = {
// student is valid
var supIdx = stuSups.findIndex(x => x.supervisor && x.supervisor.id == id_sup);
if (supIdx >= 0)
return ([stuSups[supIdx].supervisor]); // break then chain
return ([stuSups[supIdx].supervisor]); // break "then" chain
throw new Error("No supervisors related");
}
......@@ -337,12 +337,14 @@ module.exports = {
// filter from the second list those found in the first list
var sups = so.filter(a => ss.findIndex(b => b.id == a.id) >= 0);
return ([sups, Supervisor.find(id_sup)]);
})
.spread((sups, me) => {
// The requester is an office, so it has to be appended to the list of valid supervisors
sups.push(me[0]);
return sups;
return Promise.all([sups, Supervisor.find(id_sup)])
.then((arr) => {
// The requester is an office, so it has to be appended to the list of valid supervisors
// arr[0] is sups, arr[1] is the array of found supervisors (just one, the requester)
arr[0].push(arr[1][0]);
return (arr[0]);
})
.catch((err) => {throw err});
})
.then((sups) => {return callback(null, sups)})
.catch((err) => {return callback(err, [])});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment