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

Commit 40f6930

Browse files
authored
Merge pull request #139 from wordpress-mobile/issue/12399-siwa_pass_state_to_host_app
[SIWA] Send Apple credential state to host app
2 parents d098eea + b2d3120 commit 40f6930

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

WordPressAuthenticator.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "WordPressAuthenticator"
3-
s.version = "1.10.0-beta.2"
3+
s.version = "1.10.0-beta.3"
44
s.summary = "WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps."
55

66
s.description = <<-DESC

WordPressAuthenticator/Authenticator/WordPressAuthenticator.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import NSURL_IDN
44
import GoogleSignIn
55
import WordPressShared
66
import WordPressUI
7-
7+
import AuthenticationServices
88

99
// MARK: - WordPressAuthenticator: Public API to deal with WordPress.com and WordPress.org authentication.
1010
//
@@ -469,11 +469,11 @@ import WordPressUI
469469

470470
@available(iOS 13.0, *)
471471
public extension WordPressAuthenticator {
472-
473-
func checkAppleIDCredentialState(for userID: String, completion: @escaping (Bool, Error?) -> Void) {
474-
AppleAuthenticator.sharedInstance.checkAppleIDCredentialState(for: userID) { (state, error) in
472+
473+
func getAppleIDCredentialState(for userID: String, completion: @escaping (ASAuthorizationAppleIDProvider.CredentialState, Error?) -> Void) {
474+
AppleAuthenticator.sharedInstance.getAppleIDCredentialState(for: userID) { (state, error) in
475475
// If credentialState == .notFound, error will have a value.
476-
completion(state != .revoked, error)
476+
completion(state, error)
477477
}
478478
}
479479

WordPressAuthenticator/Signin/AppleAuthenticator.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ private extension AppleAuthenticator {
7777
success: { [weak self] accountCreated, existingNonSocialAccount, wpcomUsername, wpcomToken in
7878
SVProgressHUD.dismiss()
7979

80+
// Notify host app of successful Apple authentication
81+
self?.authenticationDelegate.userAuthenticatedWithAppleUserID(appleCredentials.user)
82+
8083
guard !existingNonSocialAccount else {
8184
self?.logInInstead()
8285
return
@@ -168,7 +171,6 @@ extension AppleAuthenticator: ASAuthorizationControllerDelegate {
168171
func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
169172
switch authorization.credential {
170173
case let credentials as ASAuthorizationAppleIDCredential:
171-
authenticationDelegate.userAuthenticatedWithAppleUserID(credentials.user)
172174
createWordPressComUser(appleCredentials: credentials)
173175
default:
174176
break
@@ -199,8 +201,8 @@ extension AppleAuthenticator: ASAuthorizationControllerPresentationContextProvid
199201

200202
@available(iOS 13.0, *)
201203
extension AppleAuthenticator {
202-
func checkAppleIDCredentialState(for userID: String,
203-
completion: @escaping (ASAuthorizationAppleIDProvider.CredentialState, Error?) -> Void) {
204+
func getAppleIDCredentialState(for userID: String,
205+
completion: @escaping (ASAuthorizationAppleIDProvider.CredentialState, Error?) -> Void) {
204206
ASAuthorizationAppleIDProvider().getCredentialState(forUserID: userID, completion: completion)
205207
}
206208
}

0 commit comments

Comments
 (0)