Skip to content

Commit

Permalink
Merge pull request #469 from SalesforceLabs/468-can-not-accept-terms
Browse files Browse the repository at this point in the history
Implementing a way to agree using org check in production #468
  • Loading branch information
VinceFINET authored Nov 27, 2024
2 parents 7f8bf6d + 5c41fb6 commit c47be77
Show file tree
Hide file tree
Showing 6 changed files with 898 additions and 870 deletions.
2 changes: 1 addition & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Edit the `sfdx-project.json` file to specify the namespace:
],
"namespace": "<namespace>",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "60.0"
"sourceApiVersion": "62.0"
}
```
Replace `<namespace>` with your actual namespace.
Expand Down
26 changes: 26 additions & 0 deletions force-app/main/default/lwc/orgcheckApp/api/orgcheck-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ export class OrgCheckAPI {
*/
#logger;

/**
* @property {Boolean} Is the current user accepted the terms to use Org Check in this org?
*/
#usageTermsAccepted;

/**
* Org Check constructor
*
Expand All @@ -76,6 +81,7 @@ export class OrgCheckAPI {
this.#sfdcManager = new OrgCheckSalesforceManager(jsConnectionFactory, accessToken, userId, this.#logger);
this.#datasetManager = new OrgCheckDatasetManager(this.#sfdcManager, jsCompression, this.#logger);
this.#recipeManager = new OrgCheckRecipeManager(this.#datasetManager, this.#logger);
this.#usageTermsAccepted = false;
}

/**
Expand Down Expand Up @@ -142,6 +148,26 @@ export class OrgCheckAPI {
return this.#recipeManager.run(RECIPE_ORGANIZATION_ALIAS);
}

/**
* Check if we can use the current org according to the terms (specially if this is a production org)
*
* @returns true
* @throws Exception if the org is a Production and terms are not accepted
*/
async checkUsageTerms() {
const orgInfo = await this.#recipeManager.run(RECIPE_ORGANIZATION_ALIAS);
if (orgInfo.isProduction === true) {
if (this.#usageTermsAccepted === false) {
return false;
}
}
return true;
}

acceptUsageTerms() {
this.#usageTermsAccepted = true;
}

/**
* Check if the current user can run the application
*
Expand Down
Loading

0 comments on commit c47be77

Please sign in to comment.