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

Commit 65d31b4

Browse files
authored
Merge pull request #234 from wordpress-mobile/fix/233-black-screen
Jetpack Signup Flow pushes 3 buttons instead of present
2 parents c6b885e + 99ab4a0 commit 65d31b4

File tree

2 files changed

+48
-4
lines changed

2 files changed

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

66
s.description = <<-DESC

WordPressAuthenticator/Signin/LoginEmailViewController.swift

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ open class LoginEmailViewController: LoginViewController, NUXKeyboardResponder {
4545

4646
localizeControls()
4747
setupOnePasswordButtonIfNeeded()
48-
48+
4949
alternativeLoginLabel?.isHidden = showLoginOptions
5050
if !showLoginOptions {
5151
addGoogleButton()
@@ -187,6 +187,9 @@ open class LoginEmailViewController: LoginViewController, NUXKeyboardResponder {
187187

188188
let button = WPStyleGuide.wpcomSignupButton()
189189
stackView.addArrangedSubview(button)
190+
191+
// Tapping the Sign up text link in "Don't have an account? _Sign up_"
192+
// will present the 3 button view for signing up.
190193
button.on(.touchUpInside) { [weak self] (button) in
191194
guard let vc = LoginPrologueSignupMethodViewController.instantiate(from: .login) else {
192195
DDLogError("Failed to navigate to LoginPrologueSignupMethodViewController")
@@ -199,7 +202,24 @@ open class LoginEmailViewController: LoginViewController, NUXKeyboardResponder {
199202
vc.dismissBlock = self.dismissBlock
200203
vc.transitioningDelegate = self
201204
vc.modalPresentationStyle = .custom
202-
self.navigationController?.pushViewController(vc, animated: true)
205+
206+
// Don't forget to handle the button taps!
207+
vc.emailTapped = { [weak self] in
208+
self?.performSegue(withIdentifier: .showSigninV2, sender: self)
209+
}
210+
vc.googleTapped = { [weak self] in
211+
guard let toVC = SignupGoogleViewController.instantiate(from: .signup) else {
212+
DDLogError("Failed to navigate to SignupGoogleViewController")
213+
return
214+
}
215+
216+
self?.navigationController?.pushViewController(toVC, animated: true)
217+
}
218+
vc.appleTapped = { [weak self] in
219+
self?.appleTapped()
220+
}
221+
222+
self.navigationController?.present(vc, animated: true, completion: nil)
203223
}
204224

205225
stackView.addConstraints([
@@ -374,7 +394,7 @@ open class LoginEmailViewController: LoginViewController, NUXKeyboardResponder {
374394

375395
loginWithUsernamePassword(immediately: true)
376396
}
377-
397+
378398
/// Configures loginFields to log into wordpress.com and
379399
/// navigates to the selfhosted username/password form. Displays the specified
380400
/// error message when the new view controller appears.
@@ -452,6 +472,11 @@ open class LoginEmailViewController: LoginViewController, NUXKeyboardResponder {
452472
loginToSelfHostedSite()
453473
}
454474

475+
private func appleTapped() {
476+
AppleAuthenticator.sharedInstance.delegate = self
477+
AppleAuthenticator.sharedInstance.showFrom(viewController: self)
478+
}
479+
455480

456481
@IBAction func handleTextFieldDidChange(_ sender: UITextField) {
457482
switch sender {
@@ -533,3 +558,22 @@ extension LoginEmailViewController: GIDSignInDelegate {
533558
signInGoogleAccount(signIn, didSignInFor: user, withError: error)
534559
}
535560
}
561+
562+
// MARK: - AppleAuthenticatorDelegate
563+
564+
extension LoginEmailViewController: AppleAuthenticatorDelegate {
565+
566+
func showWPComLogin(loginFields: LoginFields) {
567+
self.loginFields = loginFields
568+
performSegue(withIdentifier: .showWPComLogin, sender: self)
569+
}
570+
571+
func showApple2FA(loginFields: LoginFields) {
572+
self.loginFields = loginFields
573+
signInAppleAccount()
574+
}
575+
576+
func authFailedWithError(message: String) {
577+
displayErrorAlert(message, sourceTag: .loginApple)
578+
}
579+
}

0 commit comments

Comments
 (0)