@@ -45,7 +45,9 @@ class AuthenticationManager: Authentication {
4545 enableSignInWithApple: true ,
4646 enableSignupWithGoogle: false ,
4747 enableUnifiedAuth: true ,
48- continueWithSiteAddressFirst: true )
48+ continueWithSiteAddressFirst: true ,
49+ enableSiteCredentialsLoginForSelfHostedSites: true ,
50+ isWPComLoginRequiredForSiteCredentialsLogin: true )
4951
5052 let systemGray3LightModeColor = UIColor ( red: 199 / 255.0 , green: 199 / 255.0 , blue: 204 / 255.0 , alpha: 1 )
5153 let systemLabelLightModeColor = UIColor ( red: 0 , green: 0 , blue: 0 , alpha: 1 )
@@ -85,6 +87,7 @@ class AuthenticationManager: Authentication {
8587 usernamePasswordInstructions: AuthenticationConstants . usernamePasswordInstructions,
8688 continueWithWPButtonTitle: AuthenticationConstants . continueWithWPButtonTitle,
8789 enterYourSiteAddressButtonTitle: AuthenticationConstants . enterYourSiteAddressButtonTitle,
90+ signInWithSiteCredentialsButtonTitle: AuthenticationConstants . signInWithSiteCredsButtonTitle,
8891 findSiteButtonTitle: AuthenticationConstants . findYourStoreAddressButtonTitle,
8992 signupTermsOfService: AuthenticationConstants . signupTermsOfService,
9093 whatIsWPComLinkTitle: AuthenticationConstants . whatIsWPComLinkTitle,
@@ -260,6 +263,15 @@ extension AuthenticationManager: WordPressAuthenticatorDelegate {
260263 /// Presents the Login Epilogue, in the specified NavigationController.
261264 ///
262265 func presentLoginEpilogue( in navigationController: UINavigationController , for credentials: AuthenticatorCredentials , onDismiss: @escaping ( ) -> Void ) {
266+ let matcher = ULAccountMatcher ( )
267+ matcher. refreshStoredSites ( )
268+
269+ /// Jetpack is required. Present an error if we don't detect a valid installation for a self-hosted site.
270+ if let urlFromCredentials = credentials. wpcom? . siteURL ?? credentials. wporg? . siteURL,
271+ isJetpackValidForSelfHostedSite ( url: urlFromCredentials) {
272+ return presentJetpackError ( for: urlFromCredentials, with: credentials, in: navigationController, onDismiss: onDismiss)
273+ }
274+
263275 // We are currently supporting WPCom credentials only
264276 // Update this when handling store credentials authentication.
265277 guard let wpcomLogin = credentials. wpcom else {
@@ -270,16 +282,7 @@ extension AuthenticationManager: WordPressAuthenticatorDelegate {
270282 ServiceLocator . pushNotesManager. cancelLocalNotification ( scenarios: [ . loginSiteAddressError] )
271283 }
272284
273- let matcher = ULAccountMatcher ( )
274- matcher. refreshStoredSites ( )
275-
276285 guard matcher. match ( originalURL: wpcomLogin. siteURL) else {
277-
278- /// Jetpack is required. Present an error if we don't detect a valid installation for a self-hosted site.
279- if isJetpackValidForSelfHostedSite ( url: wpcomLogin. siteURL) {
280- return presentJetpackError ( for: wpcomLogin. siteURL, with: credentials, in: navigationController, onDismiss: onDismiss)
281- }
282-
283286 DDLogWarn ( " ⚠️ Present account mismatch error for site: \( String ( describing: credentials. wpcom? . siteURL) ) " )
284287 let viewModel = WrongAccountErrorViewModel ( siteURL: credentials. wpcom? . siteURL)
285288 let mismatchAccountUI = ULAccountMismatchViewController ( viewModel: viewModel)
@@ -447,6 +450,7 @@ private extension AuthenticationManager {
447450 in navigationController: UINavigationController ,
448451 onDismiss: @escaping ( ) -> Void ) {
449452 let viewModel = JetpackErrorViewModel ( siteURL: siteURL, onJetpackSetupCompletion: { [ weak self] in
453+ self ? . currentSelfHostedSite = nil
450454 self ? . presentLoginEpilogue ( in: navigationController, for: credentials, onDismiss: onDismiss)
451455 } )
452456 let installJetpackUI = ULErrorViewController ( viewModel: viewModel)
0 commit comments