@@ -383,7 +383,8 @@ void BraveVpnService::UpdatePurchasedStateForSessionExpired(
383
383
return ;
384
384
}
385
385
386
- SetPurchasedState (env, PurchasedState::SESSION_EXPIRED);
386
+ SetPurchasedState (env, out_of_credentials ? PurchasedState::OUT_OF_CREDENTIALS
387
+ : PurchasedState::SESSION_EXPIRED);
387
388
}
388
389
389
390
bool BraveVpnService::IsCurrentRegionSelectedAutomatically (
@@ -572,6 +573,8 @@ void BraveVpnService::OnCredentialSummary(const std::string& domain,
572
573
std::string summary_string_trimmed;
573
574
base::TrimWhitespaceASCII (summary->message , base::TrimPositions::TRIM_ALL,
574
575
&summary_string_trimmed);
576
+ // SetPurchasedState(env, PurchasedState::OUT_OF_CREDENTIALS);
577
+ // return;
575
578
if (summary_string_trimmed.length () == 0 ) {
576
579
// no credential found; person needs to login
577
580
VLOG (1 ) << __func__ << " : No credential found; user needs to login!" ;
@@ -678,6 +681,7 @@ void BraveVpnService::OnPrepareCredentialsPresentation(
678
681
return ;
679
682
}
680
683
684
+ out_of_credentials = false ;
681
685
SetSkusCredential (local_prefs_, credential, time );
682
686
683
687
if (GetCurrentEnvironment () != env) {
@@ -716,28 +720,28 @@ void BraveVpnService::OnGetSubscriberCredentialV12(
716
720
return ;
717
721
}
718
722
719
- // If we get here, we've already tried two credentials (the retry failed).
723
+ // We can set the state as FAILED and do not attempt to get another
724
+ // credential. The cached credential will eventually expire and user will
725
+ // fetch a new one.
726
+ //
727
+ // There could be two reasons for this.
728
+
729
+ // 1. We've already tried two credentials (the retry failed).
720
730
if (token_no_longer_valid && IsRetriedSkusCredential (local_prefs_)) {
721
731
VLOG (2 ) << __func__
722
732
<< " : Got TokenNoLongerValid again with retried skus credential" ;
733
+ out_of_credentials = true ;
734
+ SetPurchasedState (
735
+ GetCurrentEnvironment (), PurchasedState::FAILED,
736
+ l10n_util::GetStringUTF8 (IDS_BRAVE_VPN_PURCHASE_TOKEN_NOT_VALID));
737
+ return ;
723
738
}
724
739
725
- // When this path is reached:
726
- // - The cached credential is considered good but vendor side has an error.
727
- // That could be a network outage or a server side error on vendor side.
728
- // OR
729
- // - The cached credential is consumed and we've now tried two different
730
- // credentials.
731
- //
732
- // We set the state as FAILED and do not attempt to get another credential.
733
- // Cached credential will eventually expire and user will fetch a new one.
734
- //
735
- // This logic can be updated if we issue more than two credentials per day.
736
- auto message_id = token_no_longer_valid
737
- ? IDS_BRAVE_VPN_PURCHASE_TOKEN_NOT_VALID
738
- : IDS_BRAVE_VPN_PURCHASE_CREDENTIALS_FETCH_FAILED;
740
+ // 2. The cached credential is considered good but vendor side has an error.
741
+ // That could be a network outage or a server side error on vendor side.
739
742
SetPurchasedState (GetCurrentEnvironment (), PurchasedState::FAILED,
740
- l10n_util::GetStringUTF8 (message_id));
743
+ l10n_util::GetStringUTF8 (
744
+ IDS_BRAVE_VPN_PURCHASE_CREDENTIALS_FETCH_FAILED));
741
745
#endif
742
746
return ;
743
747
}
0 commit comments