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

Bugfix FXIOS-9906 - Send ok response to can_link_account channel message #21877

Merged
merged 1 commit into from
Sep 30, 2024
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
19 changes: 18 additions & 1 deletion firefox-ios/RustFxA/FxAWebViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ enum FxAPageType: Equatable {
// See https://mozilla.github.io/ecosystem-platform/docs/fxa-engineering/fxa-webchannel-protocol
// For details on message types.
private enum RemoteCommand: String {
// case canLinkAccount = "can_link_account"
case canLinkAccount = "fxaccounts:can_link_account"
// case loaded = "fxaccounts:loaded"
case status = "fxaccounts:fxa_status"
case oauthLogin = "fxaccounts:oauth_login"
Expand Down Expand Up @@ -283,6 +283,10 @@ extension FxAWebViewModel {
email: email,
verified: verified)
profile.rustFxA.accountManager?.setUserData(userData: userData) { }
case .canLinkAccount:
if let id = id {
onCanLinkAccount(msgId: id, webView: webView)
}
}
}
}
Expand Down Expand Up @@ -393,6 +397,19 @@ extension FxAWebViewModel {
}
}

private func onCanLinkAccount(msgId: Int, webView: WKWebView) {
let cmd = RemoteCommand.canLinkAccount.rawValue
let typeId = "account_updates"
// Respond with an 'ok' message immediately today so FxA does not need to support conditional logic on the
// server-side just for iOS.
// For proper account merging support, see: https://github.com/mozilla-mobile/firefox-ios/issues/21873
let data = """
{ "ok": true }
"""

runJS(webView: webView, typeId: typeId, messageId: msgId, command: cmd, data: data)
}

func shouldAllowRedirectAfterLogIn(basedOn navigationURL: URL?) -> WKNavigationActionPolicy {
// Cancel navigation that happens after login to an account, which is when a redirect to `redirectURL` happens.
// The app handles this event fully in native UI.
Expand Down