Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent redeeming invite codes after the VPN test ends #2559

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this since there's no reason this code shouldn't run in debug code any more. It was better this way early on, but now we can enable this.


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
Loading