From c700c1ccfbb0e25938e85a42f62dcb6fd76daf75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Buczek?= Date: Wed, 16 Nov 2022 11:37:45 +0100 Subject: [PATCH] DRY clearing sku creds. --- Client/BraveSkus/BraveSkusManager.swift | 4 +--- Sources/BraveVPN/BraveVPN.swift | 4 ++++ Sources/BraveVPN/IAPObserver.swift | 4 +--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Client/BraveSkus/BraveSkusManager.swift b/Client/BraveSkus/BraveSkusManager.swift index f8493ea83a3..bc4647be3ae 100644 --- a/Client/BraveSkus/BraveSkusManager.swift +++ b/Client/BraveSkus/BraveSkusManager.swift @@ -42,9 +42,7 @@ public class BraveSkusManager { Logger.module.debug("Refreshing sku credential. Clearing old credential from persistence.") - Preferences.VPN.skusCredential.reset() - Preferences.VPN.skusCredentialDomain.reset() - Preferences.VPN.skusCredentialExpirationDate.reset() + BraveVPN.clearSkusCredentials() manager.credentialSummary(for: domain) { completion in Logger.module.debug("credentialSummary response") diff --git a/Sources/BraveVPN/BraveVPN.swift b/Sources/BraveVPN/BraveVPN.swift index 47cd1786dba..bea14502c03 100644 --- a/Sources/BraveVPN/BraveVPN.swift +++ b/Sources/BraveVPN/BraveVPN.swift @@ -307,6 +307,10 @@ public class BraveVPN { GRDKeychain.removeGuardianKeychainItems() GRDKeychain.removeSubscriberCredential(withRetries: 3) + clearSkusCredentials() + } + + public static func clearSkusCredentials() { Preferences.VPN.skusCredential.reset() Preferences.VPN.skusCredentialDomain.reset() Preferences.VPN.skusCredentialExpirationDate.reset() diff --git a/Sources/BraveVPN/IAPObserver.swift b/Sources/BraveVPN/IAPObserver.swift index db2c8695042..70f11c98bb1 100644 --- a/Sources/BraveVPN/IAPObserver.swift +++ b/Sources/BraveVPN/IAPObserver.swift @@ -60,9 +60,7 @@ public class IAPObserver: NSObject, SKPaymentTransactionObserver { // // The user will be able to retrieve the shared credential // after log in to account.brave website. - Preferences.VPN.skusCredential.reset() - Preferences.VPN.skusCredentialDomain.reset() - Preferences.VPN.skusCredentialExpirationDate.reset() + BraveVPN.clearSkusCredentials() } else { // Receipt either expired or receipt validation returned some error. self.delegate?.purchaseFailed(error: .receiptError)