Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit 2e8f7d3

Browse files
committed
Allow host app to override login error UI in GetStartedViewController
This reverts some of the changes in 3b46ba8. That commit removed the ability for the host app to override errors. I'm applying it a bit differently here though. There was a condition added in 5cadb62 which automatically added an error dialog if the `WordPressAuthenticator.shared.configuration.enableSignUp` is `false`. The `sendEmail` is no longer called so I'm adding the override directly in `handleLoginError()`.
1 parent 040768d commit 2e8f7d3

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,22 @@ private extension GetStartedViewController {
408408
// username instead.
409409
self.showSelfHostedWithError(error)
410410
} else {
411-
self.displayError(error as NSError, sourceTag: self.sourceTag)
411+
guard let authenticationDelegate = WordPressAuthenticator.shared.delegate,
412+
authenticationDelegate.shouldHandleError(error) else {
413+
self.displayError(error as NSError, sourceTag: self.sourceTag)
414+
return
415+
}
416+
417+
/// Hand over control to the host app.
418+
authenticationDelegate.handleError(error) { customUI in
419+
// Setting the rightBarButtonItems of the custom UI before pushing the view controller
420+
// and resetting the navigationController's navigationItem after the push seems to be the
421+
// only combination that gets the Help button to show up.
422+
customUI.navigationItem.rightBarButtonItems = self.navigationItem.rightBarButtonItems
423+
self.navigationController?.navigationItem.rightBarButtonItems = self.navigationItem.rightBarButtonItems
424+
425+
self.navigationController?.pushViewController(customUI, animated: true)
426+
}
412427
}
413428
}
414429

0 commit comments

Comments
 (0)