From c059341d2b08b1fe96ebe2a3c98103444062cc8c Mon Sep 17 00:00:00 2001 From: Louis Baudoux Date: Mon, 25 Sep 2023 16:06:47 +0200 Subject: [PATCH] [IMP] iap: improve IAP accounts deactivation Setting IAP sandbox as the endpoint for IAP doesn't really neutralize the IAP services, it only prevents buying credits for it. The existing credits could still be consumed by mistake. In this new version, the account is kept as is, but the "+disabled" suffix is appended to it. This will effectively disable the service by raising a `InsufficientCreditError` for every IAP transactions. This solution has multiple advantages: - It's easy to revert, removing the "+disabled" suffix will re-activate the account. - It's retrocompatible as it doesn't require a new field on the IAP account model. - It's safer as the "disabled" information is directly part of the token, its logic is handled on the IAP side and thus common to all services. In this new version, the tokens need to be transformed as follows: original token | neutralized token --------------------|------------------- abcd1234 | acbd1234+disabled my_token+suffix123 | my_token+disabled abc+disabled | abc+disabled closes odoo/odoo#138455 X-original-commit: 550595d84b9689f3fcc00f840e9d9d6d521c5ea9 Signed-off-by: Florian Daloze (fda) Signed-off-by: Louis Baudoux (lba) --- addons/iap/data/neutralize.sql | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/addons/iap/data/neutralize.sql b/addons/iap/data/neutralize.sql index 8e14848e858..6fe84fa435b 100644 --- a/addons/iap/data/neutralize.sql +++ b/addons/iap/data/neutralize.sql @@ -1,4 +1 @@ -INSERT INTO ir_config_parameter (key, value) -VALUES ('iap.endpoint', 'https://iap-sandbox.odoo.com') - ON CONFLICT (key) DO - UPDATE SET value = 'https://iap-sandbox.odoo.com'; +UPDATE iap_account SET account_token = REGEXP_REPLACE(account_token, '(\+.*)?$', '+disabled');