Skip to content

Commit e69e58a

Browse files
author
Momo Ozawa
committed
refactor: align shouldPresentUsernamePasswordController behavior
As part of the Jetpack Focus project, we want to allow logging in without Jetpack installed. By aligning the `shouldPresentUsernamePasswordController` between WordPress and Jetpack, Jetpack users can now add non Jetpack connected self-hosted sites then install the Jetpack plugin to access the Jetpack powered features.
1 parent 243f642 commit e69e58a

3 files changed

Lines changed: 0 additions & 44 deletions

File tree

WordPress/Classes/Utility/App Configuration/AuthenticationHandler.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import WordPressAuthenticator
22

33
protocol AuthenticationHandler {
4-
func shouldPresentUsernamePasswordController(for siteInfo: WordPressComSiteInfo?, onCompletion: @escaping (WordPressAuthenticatorResult) -> Void)
54

65
/// Whether or not the AuthenticationHandler will override or handle the `presentLoginEpilogue` method.
76
/// If this returns true, the `AuthenticationHandler.presentLoginEpilogue` method is called

WordPress/Classes/ViewRelated/NUX/WordPressAuthenticationManager.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,6 @@ extension WordPressAuthenticationManager: WordPressAuthenticatorDelegate {
309309
/// - onCompletion: Closure to be executed on completion.
310310
///
311311
func shouldPresentUsernamePasswordController(for siteInfo: WordPressComSiteInfo?, onCompletion: @escaping (WordPressAuthenticatorResult) -> Void) {
312-
if let authenticationHandler = authenticationHandler {
313-
authenticationHandler.shouldPresentUsernamePasswordController(for: siteInfo, onCompletion: onCompletion)
314-
return
315-
}
316312

317313
let result: WordPressAuthenticatorResult = .presentPasswordController(value: true)
318314
onCompletion(result)

WordPress/Jetpack/Classes/JetpackAuthenticationManager.swift

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,6 @@ struct JetpackAuthenticationManager: AuthenticationHandler {
99
var prologuePrimaryButtonStyle: NUXButtonStyle? = JetpackPrologueStyleGuide.continueButtonStyle
1010
var prologueSecondaryButtonStyle: NUXButtonStyle? = JetpackPrologueStyleGuide.siteAddressButtonStyle
1111

12-
func shouldPresentUsernamePasswordController(for siteInfo: WordPressComSiteInfo?, onCompletion: @escaping (WordPressAuthenticatorResult) -> Void) {
13-
/// Jetpack is required. Present an error if we don't detect a valid installation.
14-
guard let site = siteInfo, isValidJetpack(for: site) else {
15-
let viewModel = JetpackNotFoundErrorViewModel(with: siteInfo?.url)
16-
let controller = errorViewController(with: viewModel)
17-
18-
let authenticationResult: WordPressAuthenticatorResult = .injectViewController(value: controller)
19-
onCompletion(authenticationResult)
20-
21-
return
22-
}
23-
24-
/// WordPress must be present.
25-
guard site.isWP else {
26-
let viewModel = JetpackNotWPErrorViewModel()
27-
let controller = errorViewController(with: viewModel)
28-
29-
let authenticationResult: WordPressAuthenticatorResult = .injectViewController(value: controller)
30-
onCompletion(authenticationResult)
31-
32-
return
33-
}
34-
35-
/// For self-hosted sites, navigate to enter the email address associated to the wp.com account:
36-
guard site.isWPCom else {
37-
let authenticationResult: WordPressAuthenticatorResult = .presentEmailController
38-
39-
onCompletion(authenticationResult)
40-
41-
return
42-
}
43-
44-
/// We should never reach this point, as WPAuthenticator won't call its delegate for this case.
45-
///
46-
DDLogWarn("⚠️ Present password controller for site: \(site.url)")
47-
let authenticationResult: WordPressAuthenticatorResult = .presentPasswordController(value: false)
48-
onCompletion(authenticationResult)
49-
}
50-
5112
func willHandlePresentLoginEpilogue(in navigationController: UINavigationController, for credentials: AuthenticatorCredentials) -> Bool {
5213
// Don't display the "no sites" epilogue if we allow site creation
5314
return !AppConfiguration.allowSiteCreation

0 commit comments

Comments
 (0)