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

Commit 54a066f

Browse files
authored
Merge pull request #141 from wordpress-mobile/fix/12556-siwa_wp_password_entry_fix
[SIWA] Show email address on WP password entry view
2 parents fa72a5f + a2c8052 commit 54a066f

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed

Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def wordpress_authenticator_pods
1212
##
1313
pod 'Gridicons', '~> 0.15'
1414
pod 'WordPressUI', '~> 1.3'
15-
pod 'WordPressKit', '~> 4.5.0-beta.2'
15+
pod 'WordPressKit', '~> 4.5.1-beta.1'
1616
pod 'WordPressShared', '~> 1.8'
1717

1818
## Third party libraries

Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ PODS:
4444
- Specta (1.0.7)
4545
- SVProgressHUD (2.2.5)
4646
- UIDeviceIdentifier (1.1.4)
47-
- WordPressKit (4.5.0-beta.2):
47+
- WordPressKit (4.5.1-beta.1):
4848
- Alamofire (~> 4.7.3)
4949
- CocoaLumberjack (~> 3.4)
5050
- NSObject-SafeExpectations (= 0.0.3)
@@ -71,7 +71,7 @@ DEPENDENCIES:
7171
- OHHTTPStubs/Swift (= 8.0.0)
7272
- Specta (= 1.0.7)
7373
- SVProgressHUD (= 2.2.5)
74-
- WordPressKit (~> 4.5.0-beta.2)
74+
- WordPressKit (~> 4.5.1-beta.1)
7575
- WordPressShared (~> 1.8)
7676
- WordPressUI (~> 1.3)
7777

@@ -117,11 +117,11 @@ SPEC CHECKSUMS:
117117
Specta: 3e1bd89c3517421982dc4d1c992503e48bd5fe66
118118
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
119119
UIDeviceIdentifier: 8f8a24b257a4d978c8d40ad1e7355b944ffbfa8c
120-
WordPressKit: 6fb3101e9542398c895517d64ac435d3a4e83e25
120+
WordPressKit: bab738886bfd6efe52e1d9d0d82d7fb46e30fa58
121121
WordPressShared: 34f7a1386d28d7e4650c1a225c554ee024401ca3
122122
WordPressUI: 0ea6df25bf6e63f0619376fa23870177cb37646f
123123
wpxmlrpc: 6ba55c773cfa27083ae4a2173e69b19f46da98e2
124124

125-
PODFILE CHECKSUM: 066779a8741fbd6f8205a5d3469e19c8c80682b7
125+
PODFILE CHECKSUM: 54eac1537fd4ae3b816f763cc2d73e9d3189bf05
126126

127127
COCOAPODS: 1.7.5

WordPressAuthenticator.podspec

Lines changed: 2 additions & 2 deletions
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.5"
3+
s.version = "1.10.0-beta.6"
44
s.summary = "WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps."
55

66
s.description = <<-DESC
@@ -39,6 +39,6 @@ Pod::Spec.new do |s|
3939
s.dependency 'Gridicons', '~> 0.15'
4040
s.dependency 'GoogleSignIn', '~> 4.4'
4141
s.dependency 'WordPressUI', '~> 1.3'
42-
s.dependency 'WordPressKit', '~> 4.5.0'
42+
s.dependency 'WordPressKit', '~> 4.5.1-beta.1'
4343
s.dependency 'WordPressShared', '~> 1.8'
4444
end

WordPressAuthenticator/Services/SignupService.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,19 @@ class SignupService {
7171
success(createdAccount, false, username, bearer_token)
7272
}, failure: { error in
7373
if let error = (error as NSError?) {
74+
75+
// If an account already exists, the account email should be returned in the Error response.
76+
// Extract it and return it.
77+
var existingEmail = ""
78+
if let errorData = error.userInfo[WordPressComRestApi.ErrorKeyErrorData] as? [String: String] {
79+
let emailDict = errorData.first { $0.key == WordPressComRestApi.ErrorKeyErrorDataEmail }
80+
let email = emailDict?.value ?? ""
81+
existingEmail = email
82+
}
83+
7484
let existingNonSocialAccount = (error.userInfo[ErrorKeys.errorCode] as? String ?? "") == ErrorKeys.existingNonSocialUser
7585
if existingNonSocialAccount {
76-
success(false, true, "", "")
86+
success(false, true, existingEmail, "")
7787
return
7888
}
7989
}

WordPressAuthenticator/Signin/AppleAuthenticator.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ private extension AppleAuthenticator {
8181
self?.authenticationDelegate.userAuthenticatedWithAppleUserID(appleCredentials.user)
8282

8383
guard !existingNonSocialAccount else {
84+
self?.updateLoginEmail(wpcomUsername)
8485
self?.logInInstead()
8586
return
8687
}
@@ -157,12 +158,16 @@ private extension AppleAuthenticator {
157158
}
158159

159160
func updateLoginFields(email: String, fullName: String, token: String) {
160-
loginFields.emailAddress = email
161-
loginFields.username = email
161+
updateLoginEmail(email)
162162
loginFields.meta.socialServiceIDToken = token
163163
loginFields.meta.appleUser = AppleUser(email: email, fullName: fullName)
164164
}
165165

166+
func updateLoginEmail(_ email: String) {
167+
loginFields.emailAddress = email
168+
loginFields.username = email
169+
}
170+
166171
}
167172

168173
@available(iOS 13.0, *)

0 commit comments

Comments
 (0)