Skip to content

Commit

Permalink
Fix API password gathering
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobmarin committed Oct 19, 2020
1 parent 23d0922 commit e58e516
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ const buildQuery = params => {
return query;
};

const getPassword = (role, options) => {
return options.password && options.password[role] ?
options.password[role] : config.api.password[role];
};

const getURL = (action, params, options) => {
const query = buildQuery(params);
const checksum = calculateChecksum(action, query, options);
Expand All @@ -44,8 +49,8 @@ const getCreateURL = (options) => {
const params = {
meetingID: options.room || config.url.meeting.name,
record: true,
moderatorPW: options.password.moderator || config.api.password.moderator,
attendeePW: options.password.attendee || config.api.password.attendee,
moderatorPW: getPassword('moderator', options),
attendeePW: getPassword('attendee', options),
};

return getURL('create', params, options);
Expand All @@ -54,16 +59,16 @@ const getCreateURL = (options) => {
const getEndURL = (options) => {
const params = {
meetingID: options.room || config.url.meeting.name,
password: options.password.moderator || config.api.password.moderator,
password: getPassword('moderator', options),
};

return getURL('end', params, options);
};

const getJoinURL = (username, options) => {
let password = options.password.attendee || config.api.password.attendee;
let password = getPassword('attendee', options);
if (options.moderator !== undefined ? options.moderator : config.url.moderator.value) {
password = options.password.moderator || config.api.password.moderator;
password = getPassword('moderator', options);
}

const params = {
Expand Down

0 comments on commit e58e516

Please sign in to comment.