Skip to content

Commit

Permalink
Prevent redeeming invite codes after the VPN test ends (#2559)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/414235014887631/1206789264380520/f
Tech Design URL:
CC:

Description:

This is the iOS equivalent of duckduckgo/macos-browser#2347.
  • Loading branch information
samsymons authored Mar 7, 2024
1 parent 9155824 commit 6f79d96
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions DuckDuckGo/AppDelegate+Waitlists.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Core
import BackgroundTasks
import NetworkProtection
import Waitlist
import BrowserServicesKit

extension AppDelegate {

Expand Down Expand Up @@ -51,12 +52,17 @@ extension AppDelegate {

VPNWaitlist.shared.fetchInviteCodeIfAvailable { [weak self] error in
guard error == nil else {
#if !DEBUG

if error == .alreadyHasInviteCode, UIApplication.shared.applicationState == .active {
// If the user already has an invite code but their auth token has gone missing, attempt to redeem it again.
let tokenStore = NetworkProtectionKeychainTokenStore()
let waitlistStorage = VPNWaitlist.shared.waitlistStorage
if let inviteCode = waitlistStorage.getWaitlistInviteCode(), !tokenStore.isFeatureActivated {
let configManager = ContentBlocking.shared.privacyConfigurationManager
let waitlistBetaActive = configManager.privacyConfig.isSubfeatureEnabled(NetworkProtectionSubfeature.waitlistBetaActive)

if let inviteCode = waitlistStorage.getWaitlistInviteCode(),
!tokenStore.isFeatureActivated,
waitlistBetaActive {
let pixel: Pixel.Event = .networkProtectionWaitlistRetriedInviteCodeRedemption

do {
Expand All @@ -72,7 +78,7 @@ extension AppDelegate {
self?.fetchVPNWaitlistAuthToken(inviteCode: inviteCode)
}
}
#endif

return

}
Expand Down

0 comments on commit 6f79d96

Please sign in to comment.