Skip to content

Commit

Permalink
Fix readable validation on the apps engine environment bridge (#12994)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-gubert authored and rodrigok committed Dec 19, 2018
1 parent 8e21cad commit c3eb335
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/rocketchat-apps/server/bridges/environmental.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export class AppEnvironmentalVariableBridge {
async getValueByName(envVarName, appId) {
console.log(`The App ${ appId } is getting the environmental variable value ${ envVarName }.`);

if (this.isReadable(envVarName, appId)) {
return process.env[envVarName];
if (!(await this.isReadable(envVarName, appId))) {
throw new Error(`The environmental variable "${ envVarName }" is not readable.`);
}

throw new Error(`The environmental variable "${ envVarName }" is not readable.`);
return process.env[envVarName];
}

async isReadable(envVarName, appId) {
Expand All @@ -23,10 +23,10 @@ export class AppEnvironmentalVariableBridge {
async isSet(envVarName, appId) {
console.log(`The App ${ appId } is checking if the environmental variable is set ${ envVarName }.`);

if (this.isReadable(envVarName, appId)) {
return typeof process.env[envVarName] !== 'undefined';
if (!(await this.isReadable(envVarName, appId))) {
throw new Error(`The environmental variable "${ envVarName }" is not readable.`);
}

throw new Error(`The environmental variable "${ envVarName }" is not readable.`);
return typeof process.env[envVarName] !== 'undefined';
}
}

0 comments on commit c3eb335

Please sign in to comment.