Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WordPressAuthenticator: Wiring the latest Delegate's API #9750

Merged
merged 4 commits into from
Jul 12, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ target 'WordPress' do
pod 'Gridicons', '0.16'
pod 'NSURL+IDN', '0.3'
pod 'WPMediaPicker', '1.1'
pod 'WordPressAuthenticator', '1.0.1'
pod 'WordPressAuthenticator', :git => 'https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git', :commit => 'be1e635'
pod 'WordPress-Aztec-iOS', '1.0.0-beta.23'
pod 'WordPress-Editor-iOS', '1.0.0-beta.23'
pod 'WordPressUI', '1.0.6'
Expand Down
11 changes: 8 additions & 3 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ DEPENDENCIES:
- UIDeviceIdentifier (~> 0.4)
- WordPress-Aztec-iOS (= 1.0.0-beta.23)
- WordPress-Editor-iOS (= 1.0.0-beta.23)
- WordPressAuthenticator (= 1.0.1)
- WordPressAuthenticator (from `https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git`, commit `be1e635`)
- WordPressKit (from `https://github.com/wordpress-mobile/WordPressKit-iOS.git`, commit `c2ae16bbc3fb759e0684fc9e5642d52390d00285`)
- WordPressShared (= 1.0.8)
- WordPressUI (= 1.0.6)
Expand Down Expand Up @@ -203,7 +203,6 @@ SPEC REPOS:
- UIDeviceIdentifier
- WordPress-Aztec-iOS
- WordPress-Editor-iOS
- WordPressAuthenticator
- WordPressShared
- WordPressUI
- WPMediaPicker
Expand All @@ -214,6 +213,9 @@ EXTERNAL SOURCES:
Automattic-Tracks-iOS:
:git: https://github.com/Automattic/Automattic-Tracks-iOS.git
:tag: 0.2.3
WordPressAuthenticator:
:commit: be1e635
:git: https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git
WordPressKit:
:commit: c2ae16bbc3fb759e0684fc9e5642d52390d00285
:git: https://github.com/wordpress-mobile/WordPressKit-iOS.git
Expand All @@ -222,6 +224,9 @@ CHECKOUT OPTIONS:
Automattic-Tracks-iOS:
:git: https://github.com/Automattic/Automattic-Tracks-iOS.git
:tag: 0.2.3
WordPressAuthenticator:
:commit: be1e635
:git: https://github.com/wordpress-mobile/WordPressAuthenticator-iOS.git
WordPressKit:
:commit: c2ae16bbc3fb759e0684fc9e5642d52390d00285
:git: https://github.com/wordpress-mobile/WordPressKit-iOS.git
Expand Down Expand Up @@ -263,6 +268,6 @@ SPEC CHECKSUMS:
wpxmlrpc: bfc572f62ce7ee897f6f38b098d2ba08732ecef4
ZendeskSDK: 2cda4db2ba6b10ba89aeb8dddaa94e97c85946a0

PODFILE CHECKSUM: b11fa9885d16112f988d1bfa0f76b1205468e8e1
PODFILE CHECKSUM: 77db5baf85825266e66be7808e56c872155977a4

COCOAPODS: 1.5.3
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ extension WordPressAuthenticationManager: WordPressAuthenticatorDelegate {

/// Synchronizes the specified WordPress Account.
///
func sync(credentials: WordPressCredentials, onCompletion: @escaping (Error?) -> Void) {
func sync(credentials: WordPressCredentials, onCompletion: @escaping () -> Void) {
switch credentials {
case .wpcom(let username, let authToken, let isJetpackLogin, _):
syncWPCom(username: username, authToken: authToken, isJetpackLogin: isJetpackLogin, onCompletion: onCompletion)
Expand Down Expand Up @@ -236,7 +236,7 @@ private extension WordPressAuthenticationManager {

/// Synchronizes a WordPress.com account with the specified credentials.
///
private func syncWPCom(username: String, authToken: String, isJetpackLogin: Bool, onCompletion: @escaping (Error?) -> ()) {
private func syncWPCom(username: String, authToken: String, isJetpackLogin: Bool, onCompletion: @escaping () -> ()) {
let service = WordPressComSyncService()

service.syncWPCom(username: username, authToken: authToken, isJetpackLogin: isJetpackLogin, onSuccess: { account in
Expand All @@ -247,21 +247,21 @@ private extension WordPressAuthenticationManager {
let notification = isJetpackLogin == true ? .wordpressLoginFinishedJetpackLogin : Foundation.Notification.Name(rawValue: WordPressAuthenticator.WPSigninDidFinishNotification)
NotificationCenter.default.post(name: notification, object: account)

onCompletion(nil)
onCompletion()

}, onFailure: { error in
onCompletion(error)
}, onFailure: { _ in
onCompletion()
})
}

/// Synchronizes a WordPress.org account with the specified credentials.
///
private func syncWPOrg(username: String, password: String, xmlrpc: String, options: [AnyHashable: Any], onCompletion: @escaping (Error?) -> ()) {
private func syncWPOrg(username: String, password: String, xmlrpc: String, options: [AnyHashable: Any], onCompletion: @escaping () -> ()) {
let service = BlogSyncFacade()

service.syncBlog(withUsername: username, password: password, xmlrpc: xmlrpc, options: options) { blog in
RecentSitesService().touch(blog: blog)
onCompletion(nil)
onCompletion()
}
}
}