solved several issues

parent 2ff46548
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
const moment = require('moment'); const moment = require('moment');
// //-----------------------------------------------------------------------------
// RedSys Javascript API // RedSys Javascript API
// //
const cryptojs = require("crypto-js"); const cryptojs = require("crypto-js");
...@@ -28,7 +28,7 @@ function cipherMerchantKey(order, key) { ...@@ -28,7 +28,7 @@ function cipherMerchantKey(order, key) {
function encodeMerchantParams(object) { function encodeMerchantParams(object) {
// Base64 encoding of parameters // 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); return merchantWordArray.toString(cryptojs.enc.Base64);
} }
...@@ -43,6 +43,7 @@ function signMerchantParams(params, key) { ...@@ -43,6 +43,7 @@ function signMerchantParams(params, key) {
var signature = cryptojs.HmacSHA256(params, key); var signature = cryptojs.HmacSHA256(params, key);
return signature.toString(cryptojs.enc.Base64); return signature.toString(cryptojs.enc.Base64);
} }
//-----------------------------------------------------------------------------
// //
// TPV Controller // TPV Controller
......
...@@ -324,7 +324,7 @@ module.exports = { ...@@ -324,7 +324,7 @@ module.exports = {
// student is valid // student is valid
var supIdx = stuSups.findIndex(x => x.supervisor && x.supervisor.id == id_sup); var supIdx = stuSups.findIndex(x => x.supervisor && x.supervisor.id == id_sup);
if (supIdx >= 0) if (supIdx >= 0)
return ([stuSups[supIdx].supervisor]); // break then chain return ([stuSups[supIdx].supervisor]); // break "then" chain
throw new Error("No supervisors related"); throw new Error("No supervisors related");
} }
...@@ -337,12 +337,14 @@ module.exports = { ...@@ -337,12 +337,14 @@ module.exports = {
// filter from the second list those found in the first list // filter from the second list those found in the first list
var sups = so.filter(a => ss.findIndex(b => b.id == a.id) >= 0); var sups = so.filter(a => ss.findIndex(b => b.id == a.id) >= 0);
return ([sups, Supervisor.find(id_sup)]); return Promise.all([sups, Supervisor.find(id_sup)])
}) .then((arr) => {
.spread((sups, me) => {
// The requester is an office, so it has to be appended to the list of valid supervisors // The requester is an office, so it has to be appended to the list of valid supervisors
sups.push(me[0]); // arr[0] is sups, arr[1] is the array of found supervisors (just one, the requester)
return sups; arr[0].push(arr[1][0]);
return (arr[0]);
})
.catch((err) => {throw err});
}) })
.then((sups) => {return callback(null, sups)}) .then((sups) => {return callback(null, sups)})
.catch((err) => {return callback(err, [])}); .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