Skip to content

Commit

Permalink
Fix #6221 and #6229: page dismissed after changing password
Browse files Browse the repository at this point in the history
  • Loading branch information
garvankeeley committed Mar 6, 2020
1 parent 49b0b45 commit fc9145f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 29 deletions.
4 changes: 1 addition & 3 deletions Client/Frontend/Browser/BrowserViewController.swift
Expand Up @@ -1987,9 +1987,7 @@ extension BrowserViewController: IntroViewControllerDelegate {
func getSignInOrFxASettingsVC(_ fxaOptions: FxALaunchParams? = nil, flowType: FxAPageType) -> UIViewController {
// Show the settings page if we have already signed in. If we haven't then show the signin page
guard profile.hasSyncableAccount() else {
let vc = FxAWebView(pageType: flowType, profile: profile)
vc.dismissType = .dismiss
return vc
return FxAWebView(pageType: flowType, profile: profile, dismissalStyle: .dismiss)
}

let settingsTableViewController = SyncContentSettingsViewController()
Expand Down
23 changes: 7 additions & 16 deletions Client/Frontend/Settings/AppSettingsOptions.swift
Expand Up @@ -46,7 +46,7 @@ class ConnectSetting: WithoutAccountSetting {
override var accessibilityIdentifier: String? { return "SignInToSync" }

override func onClick(_ navigationController: UINavigationController?) {
let viewController = FxAWebView(pageType: .emailLoginFlow, profile: profile)
let viewController = FxAWebView(pageType: .emailLoginFlow, profile: profile, dismissalStyle: .popToRootVC)
navigationController?.pushViewController(viewController, animated: true)
}

Expand Down Expand Up @@ -335,24 +335,15 @@ class AccountStatusSetting: WithAccountSetting {
}

override func onClick(_ navigationController: UINavigationController?) {
let fxaParams = FxALaunchParams(query: ["entrypoint": "preferences"])
let viewController = FxAContentViewController(profile: profile, fxaOptions: fxaParams)
viewController.delegate = self

let account = profile.rustAccount
if !account.accountNeedsReauth() {
let viewController = SyncContentSettingsViewController()
viewController.profile = profile
navigationController?.pushViewController(viewController, animated: true)
guard !account.accountNeedsReauth() else {
let view = FxAWebView(pageType: .emailLoginFlow, profile: profile, dismissalStyle: .popToRootVC)
navigationController?.pushViewController(view, animated: true)
return
} else {
// TODO [rustfxa] hookup re-auth case
// var cs = URLComponents(url: account.configuration.settingsURL, resolvingAgainstBaseURL: false)
// cs?.queryItems?.append(URLQueryItem(name: "email", value: account.email))
// if let url = cs?.url {
// viewController.url = url
// }
}

let viewController = SyncContentSettingsViewController()
viewController.profile = profile
navigationController?.pushViewController(viewController, animated: true)
}

Expand Down
Expand Up @@ -22,7 +22,7 @@ class ManageFxAccountSetting: Setting {
}

override func onClick(_ navigationController: UINavigationController?) {
let viewController = FxAWebView(pageType: .settingsPage, profile: profile)
let viewController = FxAWebView(pageType: .settingsPage, profile: profile, dismissalStyle: .popToRootVC)
navigationController?.pushViewController(viewController, animated: true)
}
}
Expand Down
12 changes: 3 additions & 9 deletions RustFxA/FxAWebView.swift
Expand Up @@ -33,17 +33,17 @@ fileprivate enum RemoteCommand: String {
}

class FxAWebView: UIViewController, WKNavigationDelegate {
var dismissType: DismissType = .dismiss

fileprivate let dismissType: DismissType
fileprivate var webView: WKWebView
fileprivate let pageType: FxAPageType
fileprivate var baseURL: URL?
fileprivate var helpBrowser: WKWebView?
fileprivate let profile: Profile

init(pageType: FxAPageType, profile: Profile) {
init(pageType: FxAPageType, profile: Profile, dismissalStyle: DismissType) {
self.pageType = pageType
self.profile = profile
self.dismissType = dismissalStyle

let contentController = WKUserContentController()
if let path = Bundle.main.path(forResource: "FxASignIn", ofType: "js"), let source = try? String(contentsOfFile: path, encoding: .utf8) {
Expand Down Expand Up @@ -222,12 +222,6 @@ extension FxAWebView: WKScriptMessageHandler {
RustFirefoxAccounts.shared.accountManager.handlePasswordChanged(newSessionToken: sessionToken) {
NotificationCenter.default.post(name: .RegisterForPushNotifications, object: nil)
}

if dismissType == .dismiss {
dismiss(animated: true)
} else {
navigationController?.popToRootViewController(animated: true)
}
}

func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
Expand Down

0 comments on commit fc9145f

Please sign in to comment.