Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
DRY clearing sku creds.
Browse files Browse the repository at this point in the history
  • Loading branch information
iccub committed Nov 18, 2022
1 parent 11b1ef3 commit c700c1c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 1 addition & 3 deletions Client/BraveSkus/BraveSkusManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions Sources/BraveVPN/BraveVPN.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 1 addition & 3 deletions Sources/BraveVPN/IAPObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c700c1c

Please sign in to comment.