Skip to content

Commit

Permalink
Change subscription manager to use environment variable token
Browse files Browse the repository at this point in the history
  • Loading branch information
THISISDINOSAUR committed Nov 1, 2024
1 parent 92a6d5e commit 4b4305c
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import Foundation
import Subscription
import Common
import AppKitExtensions

public protocol DataBrokerProtectionSubscriptionManaging {
var isUserAuthenticated: Bool { get }
Expand All @@ -31,20 +32,23 @@ public final class DataBrokerProtectionSubscriptionManager: DataBrokerProtection
let subscriptionManager: SubscriptionManager

public var isUserAuthenticated: Bool {
return true
subscriptionManager.accountManager.accessToken != nil
accessToken != nil
}

public var accessToken: String? {
subscriptionManager.accountManager.accessToken
// We use a staging token for privacy pro supplied through a github secret/action
// for PIR end to end tests
if NSApplication.runType == .integrationTests, let token = ProcessInfo.processInfo.environment["PRIVACYPRO_STAGING_TOKEN"] {
return token
}
return subscriptionManager.accountManager.accessToken
}

public init(subscriptionManager: SubscriptionManager) {
self.subscriptionManager = subscriptionManager
}

public func hasValidEntitlement() async throws -> Bool {
return true
switch await subscriptionManager.accountManager.hasEntitlement(forProductName: .dataBrokerProtection,
cachePolicy: .reloadIgnoringLocalCacheData) {
case let .success(result):
Expand Down

0 comments on commit 4b4305c

Please sign in to comment.