Skip to content

Commit

Permalink
Bugfix FXIOS-9906 - Send ok response to can_link_account channel message
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalmeida committed Sep 25, 2024
1 parent 9e9aa1a commit 4b60ea4
Showing 1 changed file with 18 additions and 1 deletion.
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

0 comments on commit 4b60ea4

Please sign in to comment.