Skip to content

Commit

Permalink
should be picking the org in the client field, not the first org
Browse files Browse the repository at this point in the history
  • Loading branch information
dshuffma-ibm committed Sep 22, 2017
1 parent dc7b6da commit 3b028d9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion routes/site_router.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function build_bag(req) {
//get cred data
function get_credential_data() {
const channel = helper.getChannelId();
const first_org = helper.getFirstOrg();
const first_org = helper.getClientOrg();
const first_ca = helper.getFirstCaName(first_org);
const first_peer = helper.getFirstPeerName(channel);
const first_orderer = helper.getFirstOrdererName(channel);
Expand Down
34 changes: 21 additions & 13 deletions utils/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,14 @@ module.exports = function (config_filename, logger) {
throw new Error('Orgs not found.');
};

// find the org name in the client field
helper.getClientOrg = function () {
if (helper.creds.client && helper.creds.client.organization) {
return helper.creds.client.organization;
}
throw new Error('Org not found.');
};

// get this org's msp id
helper.getOrgsMSPid = function (key) {
if (key === undefined || key == null) {
Expand Down Expand Up @@ -485,8 +493,8 @@ module.exports = function (config_filename, logger) {
// build the marbles lib module options
helper.makeMarblesLibOptions = function () {
const channel = helper.getChannelId();
const first_org = helper.getFirstOrg();
const first_ca = helper.getFirstCaName(first_org);
const org_2_use = helper.getClientOrg();
const first_ca = helper.getFirstCaName(org_2_use);
const first_peer = helper.getFirstPeerName(channel);
const first_orderer = helper.getFirstOrdererName(channel);
return {
Expand All @@ -508,11 +516,11 @@ module.exports = function (config_filename, logger) {
throw new Error('User index not passed');
} else {
const channel = helper.getChannelId();
const first_org = helper.getFirstOrg();
const first_ca = helper.getFirstCaName(first_org);
const org_2_use = helper.getClientOrg();
const first_ca = helper.getFirstCaName(org_2_use);
const first_peer = helper.getFirstPeerName(channel);
const first_orderer = helper.getFirstOrdererName(channel);
const org_name = helper.getOrgsMSPid(first_org); //lets use the first org we find
const org_name = helper.getOrgsMSPid(org_2_use); //lets use the first org we find
const user_obj = helper.getEnrollObj(first_ca, userIndex); //there may be multiple users
return {
channel_id: channel,
Expand All @@ -535,10 +543,10 @@ module.exports = function (config_filename, logger) {
// build the enrollment options using an admin cert
helper.makeEnrollmentOptionsUsingCert = function () {
const channel = helper.getChannelId();
const first_org = helper.getFirstOrg();
const org_2_use = helper.getClientOrg();
const first_peer = helper.getFirstPeerName(channel);
const first_orderer = helper.getFirstOrdererName(channel);
const org_name = helper.getOrgsMSPid(first_org); //lets use the first org we find
const org_name = helper.getOrgsMSPid(org_2_use); //lets use the first org we find
return {
channel_id: channel,
uuid: helper.makeUniqueId(),
Expand All @@ -558,9 +566,9 @@ module.exports = function (config_filename, logger) {
console.log('saving the creds file has been disabled temporarily');

const channel = helper.getChannelId();
const first_org = helper.getFirstOrg();
const org_2_use = helper.getClientOrg();
const first_peer = helper.getFirstPeerName(channel);
const first_ca = helper.getFirstCaName(first_org);
const first_ca = helper.getFirstCaName(org_2_use);
const first_orderer = helper.getFirstOrdererName(channel);

//var config_file = JSON.parse(fs.readFileSync(helper.config_path, 'utf8'));
Expand Down Expand Up @@ -659,8 +667,8 @@ module.exports = function (config_filename, logger) {
if (!channel) {
errors.push('There is no channel data in the "channels" field');
} else {
const first_org = helper.getFirstOrg();
const first_ca = helper.getFirstCaName(first_org);
const org_2_use = helper.getClientOrg();
const first_ca = helper.getFirstCaName(org_2_use);
const first_orderer = helper.getFirstOrdererName(channel);
const first_peer = helper.getFirstPeerName(channel);

Expand Down Expand Up @@ -700,8 +708,8 @@ module.exports = function (config_filename, logger) {
helper.check_protocols = function () {
let errors = [];
const channel = helper.getChannelId();
const first_org = helper.getFirstOrg();
const first_ca = helper.getFirstCaName(first_org);
const org_2_use = helper.getClientOrg();
const first_ca = helper.getFirstCaName(org_2_use);
const first_orderer = helper.getFirstOrdererName(channel);
const first_peer = helper.getFirstPeerName(channel);

Expand Down

0 comments on commit 3b028d9

Please sign in to comment.