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

Commit 2137f07

Browse files
authored
Merge pull request #62 from wordpress-mobile/issues/wpcom-credentials-change
Issues/wpcom credentials change
2 parents 7c81a86 + 867fa63 commit 2137f07

File tree

12 files changed

+22
-27
lines changed

12 files changed

+22
-27
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.1.12-beta.1"
3+
s.version = "1.2.0-beta.1"
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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,7 @@ import WordPressUI
247247
return false
248248
}
249249

250-
guard let loginFields = retrieveLoginInfoForTokenAuth() else {
251-
DDLogInfo("App opened with authentication link but info wasn't found for token.")
252-
return false
253-
}
250+
let loginFields = retrieveLoginInfoForTokenAuth()
254251

255252
// The only time we should expect a magic link login when there is already a default wpcom account
256253
// is when a user is logging into Jetpack.
@@ -265,7 +262,6 @@ import WordPressUI
265262
return false
266263
}
267264
loginController.loginFields = loginFields
268-
loginController.email = loginFields.username
269265
loginController.token = token
270266
let controller = loginController
271267

@@ -370,13 +366,14 @@ import WordPressUI
370366
///
371367
/// - Returns: A loginFields instance or nil.
372368
///
373-
class func retrieveLoginInfoForTokenAuth() -> LoginFields? {
369+
class func retrieveLoginInfoForTokenAuth() -> LoginFields {
370+
371+
let loginFields = LoginFields()
374372

375373
guard let dict = UserDefaults.standard.dictionary(forKey: Constants.authenticationInfoKey) else {
376-
return nil
374+
return loginFields
377375
}
378376

379-
let loginFields = LoginFields()
380377
if let username = dict[Constants.username] as? String {
381378
loginFields.username = username
382379
}

WordPressAuthenticator/Credentials/WordPressCredentials.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ public enum WordPressCredentials {
99

1010
/// WordPress.com Site Credentials.
1111
///
12-
case wpcom(username: String, authToken: String, isJetpackLogin: Bool, multifactor: Bool)
12+
case wpcom(authToken: String, isJetpackLogin: Bool, multifactor: Bool)
1313
}

WordPressAuthenticator/NUX/NUXLinkAuthViewController.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ import WordPressShared
99
///
1010
class NUXLinkAuthViewController: LoginViewController {
1111
@IBOutlet weak var statusLabel: UILabel?
12-
@objc var email: String = ""
1312
@objc var token: String = ""
1413
@objc var didSync: Bool = false
1514

1615
override func viewDidAppear(_ animated: Bool) {
1716
super.viewDidAppear(animated)
1817

19-
// Gotta have email and token to use this vc
20-
assert(!email.isEmpty, "Email cannot be nil")
18+
// Gotta have a token to use this vc
2119
assert(!token.isEmpty, "Email token cannot be nil")
2220

2321
if didSync {
@@ -26,7 +24,7 @@ class NUXLinkAuthViewController: LoginViewController {
2624

2725
didSync = true // Make sure we don't call this twice by accident
2826

29-
let credentials = WordPressCredentials.wpcom(username: email, authToken: token, isJetpackLogin: isJetpackLogin, multifactor: false)
27+
let credentials = WordPressCredentials.wpcom(authToken: token, isJetpackLogin: isJetpackLogin, multifactor: false)
3028
syncWPComAndPresentEpilogue(credentials: credentials)
3129

3230
// Count this as success since we're authed. Even if there is a glitch

WordPressAuthenticator/Services/LoginFacade.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,10 @@ NS_ASSUME_NONNULL_BEGIN
150150
/**
151151
* Called when finished logging in to a WordPress.com site
152152
*
153-
* @param username username of the site
154153
* @param authToken authToken to be used to access the site
155154
* @param requiredMultifactorCode whether the login required a 2fa code
156155
*/
157-
- (void)finishedLoginWithUsername:(NSString *)username authToken:(NSString *)authToken requiredMultifactorCode:(BOOL)requiredMultifactorCode;
156+
- (void)finishedLoginWithAuthToken:(NSString *)authToken requiredMultifactorCode:(BOOL)requiredMultifactorCode;
158157

159158

160159
/**

WordPressAuthenticator/Services/LoginFacade.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ - (void)signInToWordpressDotCom:(LoginFields *)loginFields
122122
}
123123

124124
[self.wordpressComOAuthClientFacade authenticateWithUsername:loginFields.username password:loginFields.password multifactorCode:loginFields.multifactorCode success:^(NSString *authToken) {
125-
if ([self.delegate respondsToSelector:@selector(finishedLoginWithUsername:authToken:requiredMultifactorCode:)]) {
126-
[self.delegate finishedLoginWithUsername:loginFields.username authToken:authToken requiredMultifactorCode:loginFields.meta.requiredMultifactor];
125+
if ([self.delegate respondsToSelector:@selector(finishedLoginWithAuthToken:requiredMultifactorCode:)]) {
126+
[self.delegate finishedLoginWithAuthToken:authToken requiredMultifactorCode:loginFields.meta.requiredMultifactor];
127127
}
128128
} needsMultiFactor:^{
129129
if ([self.delegate respondsToSelector:@selector(needsMultifactorCode)]) {

WordPressAuthenticator/Signin/Login2FAViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class Login2FAViewController: LoginViewController, NUXKeyboardResponder, UITextF
172172
}
173173

174174
func finishedLogin(withNonceAuthToken authToken: String) {
175-
let credentials = WordPressCredentials.wpcom(username: loginFields.username, authToken: authToken, isJetpackLogin: isJetpackLogin, multifactor: true)
175+
let credentials = WordPressCredentials.wpcom(authToken: authToken, isJetpackLogin: isJetpackLogin, multifactor: true)
176176
syncWPComAndPresentEpilogue(credentials: credentials)
177177

178178
// Disconnect now that we're done with Google.

WordPressAuthenticator/Signin/LoginEmailViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ open class LoginEmailViewController: LoginViewController, NUXKeyboardResponder {
538538
// LoginFacadeDelegate methods for Google Google Sign In
539539
extension LoginEmailViewController {
540540
func finishedLogin(withGoogleIDToken googleIDToken: String, authToken: String) {
541-
let credentials = WordPressCredentials.wpcom(username: loginFields.username, authToken: authToken, isJetpackLogin: isJetpackLogin, multifactor: false)
541+
let credentials = WordPressCredentials.wpcom(authToken: authToken, isJetpackLogin: isJetpackLogin, multifactor: false)
542542
syncWPComAndPresentEpilogue(credentials: credentials)
543543

544544
// Disconnect now that we're done with Google.

WordPressAuthenticator/Signin/LoginViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ open class LoginViewController: NUXViewController, LoginFacadeDelegate {
155155
}
156156

157157
// MARK: SigninWPComSyncHandler methods
158-
dynamic open func finishedLogin(withUsername username: String, authToken: String, requiredMultifactorCode: Bool) {
159-
let credentials = WordPressCredentials.wpcom(username: username, authToken: authToken, isJetpackLogin: isJetpackLogin, multifactor: requiredMultifactorCode)
158+
dynamic open func finishedLogin(withAuthToken authToken: String, requiredMultifactorCode: Bool) {
159+
let credentials = WordPressCredentials.wpcom(authToken: authToken, isJetpackLogin: isJetpackLogin, multifactor: requiredMultifactorCode)
160160

161161
syncWPComAndPresentEpilogue(credentials: credentials)
162162

@@ -247,7 +247,7 @@ extension LoginViewController {
247247
switch credentials {
248248
case .wporg:
249249
break
250-
case .wpcom(_, _, _, let multifactor):
250+
case .wpcom(_, _, let multifactor):
251251
properties = [
252252
"multifactor": multifactor.description,
253253
"dotcom_user": true.description

WordPressAuthenticator/Signup/SignupGoogleViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private extension SignupGoogleViewController {
100100

101101
service.createWPComUserWithGoogle(token: googleToken, success: { [weak self] accountCreated, wpcomUsername, wpcomToken in
102102

103-
let credentials = WordPressCredentials.wpcom(username: wpcomUsername, authToken: wpcomToken, isJetpackLogin: false, multifactor: false)
103+
let credentials = WordPressCredentials.wpcom(authToken: wpcomToken, isJetpackLogin: false, multifactor: false)
104104

105105
/// New Account: We'll signal the host app right away!
106106
///

0 commit comments

Comments
 (0)