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

Only attempt to refresh auth token when user is authenticated #3721

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11723,7 +11723,7 @@
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 221.0.0;
version = "221.0.0-1";
};
};
9F8FE9472BAE50E50071E372 /* XCRemoteSwiftPackageReference "lottie-spm" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/DuckDuckGo/BrowserServicesKit",
"state" : {
"revision" : "9975e63265e617ce9c25ae1be6d531f6de5e6592",
"version" : "221.0.0"
"revision" : "276754fc1efab85c39a77da64e68439e7f105de3",
"version" : "221.0.0-1"
}
},
{
Expand Down Expand Up @@ -138,7 +138,7 @@
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "0fbc8848e389af3bb55c182bc19ca9d5dc2f255b",
"version" : "1.4.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,14 @@ final class SubscriptionPagesUseSubscriptionFeature: Subfeature, ObservableObjec
// MARK: Broker Methods (Called from WebView via UserScripts)

func getSubscription(params: Any, original: WKScriptMessage) async -> Encodable? {
await appStoreAccountManagementFlow.refreshAuthTokenIfNeeded()
let authToken = accountManager.authToken ?? Constants.empty
guard accountManager.isUserAuthenticated else { return [Constants.token: Constants.empty] }

return [Constants.token: authToken]
switch await appStoreAccountManagementFlow.refreshAuthTokenIfNeeded() {
case .success(let currentAuthToken):
return [Constants.token: currentAuthToken]
case .failure:
return [Constants.token: Constants.empty]
}
}

func getSubscriptionOptions(params: Any, original: WKScriptMessage) async -> Encodable? {
Expand Down
Loading