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

Commit 7115714

Browse files
authored
Merge pull request #574 from wordpress-mobile/task/send_email_after_email_entered
Shorter sign up - remove Send Link by email screen
2 parents 1108c68 + d49a0b8 commit 7115714

File tree

4 files changed

+48
-26
lines changed

4 files changed

+48
-26
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.35.0"
3+
s.version = "1.35.1"
44
s.summary = "WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps."
55

66
s.description = <<-DESC

WordPressAuthenticator/Authenticator/WordPressAuthenticatorDisplayStrings.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public struct WordPressAuthenticatorDisplayStrings {
1717
public let openMailSignupInstructions: String
1818
public let openMailLoginInstructions: String
1919
public let checkSpamInstructions: String
20+
public let oopsInstructions: String
2021
public let googleSignupInstructions: String
2122
public let googlePasswordInstructions: String
2223
public let applePasswordInstructions: String
@@ -67,6 +68,7 @@ public struct WordPressAuthenticatorDisplayStrings {
6768
openMailSignupInstructions: String = defaultStrings.openMailSignupInstructions,
6869
openMailLoginInstructions: String = defaultStrings.openMailLoginInstructions,
6970
checkSpamInstructions: String = defaultStrings.checkSpamInstructions,
71+
oopsInstructions: String = defaultStrings.oopsInstructions,
7072
googleSignupInstructions: String = defaultStrings.googleSignupInstructions,
7173
googlePasswordInstructions: String = defaultStrings.googlePasswordInstructions,
7274
applePasswordInstructions: String = defaultStrings.applePasswordInstructions,
@@ -102,6 +104,7 @@ public struct WordPressAuthenticatorDisplayStrings {
102104
self.openMailSignupInstructions = openMailSignupInstructions
103105
self.openMailLoginInstructions = openMailLoginInstructions
104106
self.checkSpamInstructions = checkSpamInstructions
107+
self.oopsInstructions = oopsInstructions
105108
self.googleSignupInstructions = googleSignupInstructions
106109
self.googlePasswordInstructions = googlePasswordInstructions
107110
self.applePasswordInstructions = applePasswordInstructions
@@ -153,6 +156,7 @@ public extension WordPressAuthenticatorDisplayStrings {
153156
openMailLoginInstructions: NSLocalizedString("Check your email on this device, and tap the link in the email you receive from WordPress.com.",
154157
comment: "Instruction text after a login Magic Link was requested."),
155158
checkSpamInstructions: NSLocalizedString("Not seeing the email? Check your Spam or Junk Mail folder.", comment: "Instructions after a Magic Link was sent, but the email can't be found in their inbox."),
159+
oopsInstructions: NSLocalizedString("Didn't mean to create a new account? Go back to re-enter your email address.", comment: "Instructions after a Magic Link was sent, but email is incorrect."),
156160
googleSignupInstructions: NSLocalizedString("We'll use this email address to create your new WordPress.com account.", comment: "Text confirming email address to be used for new account."),
157161
googlePasswordInstructions: NSLocalizedString("To proceed with this Google account, please first log in with your WordPress.com password. This will only be asked once.",
158162
comment: "Instructional text shown when requesting the user's password for Google login."),

WordPressAuthenticator/Unified Auth/View Related/Get Started/GetStartedViewController.swift

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ private extension GetStartedViewController {
401401
let errorCode = userInfo[WordPressComRestApi.ErrorKeyErrorCode] as? String
402402

403403
if errorCode == "unknown_user" {
404-
self.showSignupViewIfNecessary(error)
404+
self.sendEmail()
405405
} else if errorCode == "email_login_not_allowed" {
406406
// If we get this error, we know we have a WordPress.com user but their
407407
// email address is flagged as suspicious. They need to login via their
@@ -411,36 +411,45 @@ private extension GetStartedViewController {
411411
self.displayError(error as NSError, sourceTag: self.sourceTag)
412412
}
413413
}
414+
415+
// MARK: - Send email
414416

415-
/// Offer host apps the opportunity to decide if they want to allow signups
417+
/// Makes the call to request a magic signup link be emailed to the user.
416418
///
417-
func showSignupViewIfNecessary(_ error: Error) {
418-
guard let authenticationDelegate = WordPressAuthenticator.shared.delegate, authenticationDelegate.shouldHandleError(error) else {
419-
showSignupView()
420-
return
421-
}
419+
private func sendEmail() {
420+
tracker.set(flow: .signup)
421+
loginFields.meta.emailMagicLinkSource = .signup
422422

423-
/// Hand over control to the host app.
424-
authenticationDelegate.handleError(error) { customUI in
425-
// Setting the rightBarButtonItems of the custom UI before pushing the view controller
426-
// and resetting the navigationController's navigationItem after the push seems to be the
427-
// only combination that gets the Help button to show up.
428-
customUI.navigationItem.rightBarButtonItems = self.navigationItem.rightBarButtonItems
429-
self.navigationController?.navigationItem.rightBarButtonItems = self.navigationItem.rightBarButtonItems
423+
configureSubmitButton(animating: true)
430424

431-
self.navigationController?.pushViewController(customUI, animated: true)
432-
}
425+
let service = WordPressComAccountService()
426+
service.requestSignupLink(for: loginFields.username,
427+
success: { [weak self] in
428+
self?.didRequestSignupLink()
429+
self?.configureSubmitButton(animating: false)
430+
431+
}, failure: { [weak self] (error: Error) in
432+
DDLogError("Request for signup link email failed.")
433+
434+
guard let self = self else {
435+
return
436+
}
437+
438+
self.tracker.track(failure: error.localizedDescription)
439+
self.displayError(error as NSError, sourceTag: self.sourceTag)
440+
self.configureSubmitButton(animating: false)
441+
})
433442
}
434-
435-
/// Show the Sign Up view.
436-
///
437-
func showSignupView() {
438-
guard let vc = UnifiedSignupViewController.instantiate(from: .unifiedSignup) else {
439-
DDLogError("Failed to navigate to UnifiedSignupViewController from GetStartedViewController")
443+
444+
private func didRequestSignupLink() {
445+
guard let vc = SignupMagicLinkViewController.instantiate(from: .unifiedSignup) else {
446+
DDLogError("Failed to navigate from UnifiedSignupViewController to SignupMagicLinkViewController")
440447
return
441448
}
442-
449+
443450
vc.loginFields = loginFields
451+
vc.loginFields.restrictToWPCom = true
452+
444453
navigationController?.pushViewController(vc, animated: true)
445454
}
446455

WordPressAuthenticator/Unified Auth/View Related/Sign up/SignupMagicLinkViewController.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private extension SignupMagicLinkViewController {
132132
/// Describes how the tableView rows should be rendered.
133133
///
134134
func loadRows() {
135-
rows = [.persona, .instructions, .checkSpam]
135+
rows = [.persona, .instructions, .checkSpam, .oops]
136136
}
137137

138138
/// Configure cells.
@@ -145,6 +145,8 @@ private extension SignupMagicLinkViewController {
145145
configureInstructionLabel(cell)
146146
case let cell as TextLabelTableViewCell where row == .checkSpam:
147147
configureCheckSpamLabel(cell)
148+
case let cell as TextLabelTableViewCell where row == .oops:
149+
configureoopsLabel(cell)
148150
default:
149151
DDLogError("Error: Unidentified tableViewCell type found.")
150152
}
@@ -167,6 +169,12 @@ private extension SignupMagicLinkViewController {
167169
func configureCheckSpamLabel(_ cell: TextLabelTableViewCell) {
168170
cell.configureLabel(text: WordPressAuthenticator.shared.displayStrings.checkSpamInstructions, style: .body)
169171
}
172+
173+
/// Configure the "Check spam" cell.
174+
///
175+
func configureoopsLabel(_ cell: TextLabelTableViewCell) {
176+
cell.configureLabel(text: WordPressAuthenticator.shared.displayStrings.oopsInstructions, style: .body)
177+
}
170178

171179
// MARK: - Private Constants
172180

@@ -176,12 +184,13 @@ private extension SignupMagicLinkViewController {
176184
case persona
177185
case instructions
178186
case checkSpam
187+
case oops
179188

180189
var reuseIdentifier: String {
181190
switch self {
182191
case .persona:
183192
return GravatarEmailTableViewCell.reuseIdentifier
184-
case .instructions, .checkSpam:
193+
case .instructions, .checkSpam, .oops:
185194
return TextLabelTableViewCell.reuseIdentifier
186195
}
187196
}

0 commit comments

Comments
 (0)