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

Commit 9d61ed1

Browse files
authored
Merge pull request #45 from wordpress-mobile/issue/5166-login_with_site
Prompt user to logout before connecting to WPCom site
2 parents 3803f7a + 895563c commit 9d61ed1

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,6 @@ SPEC CHECKSUMS:
121121
WordPressUI: af141587ec444f9af753a00605bd0d3f14d8d8a3
122122
wpxmlrpc: 6ba55c773cfa27083ae4a2173e69b19f46da98e2
123123

124-
PODFILE CHECKSUM: f32a09c9b495b518f6426d0baad6f5c28cc22545
124+
PODFILE CHECKSUM: cd63cfaba8f70b78fe639f5db17d4efa2049df04
125125

126126
COCOAPODS: 1.5.3

WordPressAuthenticator.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ Pod::Spec.new do |s|
3434
s.dependency 'Gridicons', '~> 0.15'
3535
s.dependency 'GoogleSignInRepacked', '4.1.2'
3636
s.dependency 'WordPressUI', '~> 1.0'
37-
s.dependency 'WordPressKit', '~> 1.7'
37+
s.dependency 'WordPressKit', '~> 1.7.0-beta'
3838
s.dependency 'WordPressShared', '~> 1.4'
3939
end

WordPressAuthenticator/Authenticator/WordPressAuthenticatorDelegateProtocol.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public protocol WordPressAuthenticatorDelegate: class {
2020
///
2121
var supportEnabled: Bool { get }
2222

23+
/// Returns true if there isn't a default WordPress.com account connected in the app.
24+
var allowWPComLogin: Bool { get }
25+
2326
/// Signals the Host App that a new WordPress.com account has just been created.
2427
///
2528
/// - Parameters:

WordPressAuthenticator/Signin/LoginSiteAddressViewController.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,13 @@ class LoginSiteAddressViewController: LoginViewController, NUXKeyboardResponder
187187
let service = WordPressComBlogService()
188188
service.fetchSiteInfo(for: siteAddress, success: { [weak self] siteInfo in
189189
self?.loginFields.meta.siteInfo = siteInfo
190-
self?.showSelfHostedUsernamePassword()
190+
if WordPressAuthenticator.shared.delegate?.allowWPComLogin == false {
191+
self?.promptUserToLogoutBeforeConnectingWPComSite()
192+
self?.configureViewLoading(false)
193+
} else {
194+
self?.showSelfHostedUsernamePassword()
195+
}
196+
191197
}, failure: { [weak self] (error) in
192198
self?.showSelfHostedUsernamePassword()
193199
})
@@ -227,6 +233,13 @@ class LoginSiteAddressViewController: LoginViewController, NUXKeyboardResponder
227233
return loginFields.validateSiteForSignin()
228234
}
229235

236+
@objc private func promptUserToLogoutBeforeConnectingWPComSite() {
237+
let acceptActionTitle = NSLocalizedString("OK", comment: "Alert dismissal title")
238+
let message = NSLocalizedString("Please log out before connecting to a different wordpress.com site", comment: "Message for alert to prompt user to logout before connecting to a different wordpress.com site.")
239+
let alertController = UIAlertController(title: nil, message: message, preferredStyle: .alert)
240+
alertController.addDefaultActionWithTitle(acceptActionTitle)
241+
present(alertController, animated: true)
242+
}
230243

231244
// MARK: - Actions
232245

0 commit comments

Comments
 (0)