Skip to content

Commit

Permalink
Hide site credential login button from Get Started screen after enter…
Browse files Browse the repository at this point in the history
…ing a WPCom site address (#855)
  • Loading branch information
itsmeichigo authored Aug 16, 2024
2 parents 88d1755 + 0a18a7d commit 08a25e9
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 24 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ _None._

_None._

## 9.0.9

### Bug Fixes

- Hide site credential login option from Get Started screen after entering a WPCom site address [#855]

## 9.0.8

### Internal Changes
Expand Down
4 changes: 2 additions & 2 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PODS:
- SVProgressHUD (2.2.5)
- SwiftLint (0.54.0)
- UIDeviceIdentifier (2.3.0)
- WordPressAuthenticator (9.0.8):
- WordPressAuthenticator (9.0.9):
- Gridicons (~> 1.0)
- "NSURL+IDN (= 0.4)"
- SVProgressHUD (~> 2.2.5)
Expand Down Expand Up @@ -67,7 +67,7 @@ SPEC CHECKSUMS:
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
SwiftLint: c1de071d9d08c8aba837545f6254315bc900e211
UIDeviceIdentifier: 442b65b4ff1832d4ca9c2a157815cb29ad981b17
WordPressAuthenticator: f396f27104420ef617ffdc73dc76fab169508867
WordPressAuthenticator: f8dcccf4661255208fb54e5558b5175e1f5bdda9
WordPressKit: a71cc550f4b525ab5eef057984c8de071462edd5
WordPressShared: 87f3ee89b0a3e83106106f13a8b71605fb8eb6d2
WordPressUI: a491454affda3b0fb812812e637dc5e8f8f6bd06
Expand Down
2 changes: 1 addition & 1 deletion WordPressAuthenticator.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Pod::Spec.new do |s|
s.name = 'WordPressAuthenticator'
s.version = '9.0.8'
s.version = '9.0.9'

s.summary = 'WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps.'
s.description = <<-DESC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public enum SignInError: Error {
class GetStartedViewController: LoginViewController, NUXKeyboardResponder {

private enum ScreenMode {
/// For signing in using .org site credentials
/// For signing in using site address
///
case signInUsingSiteCredentials
case signInUsingSiteAddress(isWPComSite: Bool)

/// For signing in using WPCOM credentials or social accounts
case signInUsingWordPressComOrSocialAccounts
Expand Down Expand Up @@ -87,14 +87,17 @@ class GetStartedViewController: LoginViewController, NUXKeyboardResponder {

private var passwordCoordinator: PasswordCoordinator?

// This is internal so it can be set from SiteAddressViewController.
var wpcomSiteAddressDetected = false

/// Sign in with site credentials button will be displayed based on the `screenMode`
///
private var screenMode: ScreenMode {
guard configuration.enableSiteCredentialsLoginForSelfHostedSites,
loginFields.siteAddress.isEmpty == false else {
return .signInUsingWordPressComOrSocialAccounts
}
return .signInUsingSiteCredentials
return .signInUsingSiteAddress(isWPComSite: wpcomSiteAddressDetected)
}

// Submit button displayed in the table footer.
Expand Down Expand Up @@ -145,8 +148,8 @@ class GetStartedViewController: LoginViewController, NUXKeyboardResponder {
setupTableFooterView()
configureDivider()

if screenMode == .signInUsingSiteCredentials {
configureButtonViewControllerForSiteCredentialsMode()
if case .signInUsingSiteAddress(let isWPComSite) = screenMode {
configureButtonViewControllerForSiteAddressMode(isWPComSite: isWPComSite)
} else if configuration.enableSocialLogin == false {
configureButtonViewControllerWithoutSocialLogin()
} else {
Expand Down Expand Up @@ -462,7 +465,7 @@ private extension GetStartedViewController {
func configureAnalyticsTracker() {
// Configure tracker flow based on screen mode.
switch screenMode {
case .signInUsingSiteCredentials:
case .signInUsingSiteAddress:
tracker.set(flow: .loginWithSiteAddress)
case .signInUsingWordPressComOrSocialAccounts:
tracker.set(flow: .wpCom)
Expand Down Expand Up @@ -803,7 +806,7 @@ private extension GetStartedViewController {
termsButton.addTarget(self, action: #selector(termsTapped), for: .touchUpInside)
}

func configureButtonViewControllerForSiteCredentialsMode() {
func configureButtonViewControllerForSiteAddressMode(isWPComSite: Bool) {
guard let buttonViewController = buttonViewController else {
return
}
Expand All @@ -813,11 +816,13 @@ private extension GetStartedViewController {
if configuration.enableSocialLogin {
configureSocialButtons()

// Setup Sign in with site credentials button
buttonViewController.setupTertiaryButton(attributedTitle: WPStyleGuide.formattedSignInWithSiteCredentialsString(),
isPrimary: false,
accessibilityIdentifier: ButtonConfiguration.SignInWithSiteCredentials.accessibilityIdentifier) { [weak self] in
self?.handleSiteCredentialsButtonTapped()
if isWPComSite == false {
// Setup Sign in with site credentials button
buttonViewController.setupTertiaryButton(attributedTitle: WPStyleGuide.formattedSignInWithSiteCredentialsString(),
isPrimary: false,
accessibilityIdentifier: ButtonConfiguration.SignInWithSiteCredentials.accessibilityIdentifier) { [weak self] in
self?.handleSiteCredentialsButtonTapped()
}
}
} else {
// Add a "Continue" button here as the `continueButton` at the top will be hidden
Expand All @@ -830,11 +835,13 @@ private extension GetStartedViewController {
}
}

// Setup Sign in with site credentials button
buttonViewController.setupBottomButton(attributedTitle: WPStyleGuide.formattedSignInWithSiteCredentialsString(),
isPrimary: false,
accessibilityIdentifier: ButtonConfiguration.SignInWithSiteCredentials.accessibilityIdentifier) { [weak self] in
self?.handleSiteCredentialsButtonTapped()
if isWPComSite == false {
// Setup Sign in with site credentials button
buttonViewController.setupBottomButton(attributedTitle: WPStyleGuide.formattedSignInWithSiteCredentialsString(),
isPrimary: false,
accessibilityIdentifier: ButtonConfiguration.SignInWithSiteCredentials.accessibilityIdentifier) { [weak self] in
self?.handleSiteCredentialsButtonTapped()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ private extension SiteAddressViewController {
}

guard siteInfo?.isWPCom == false else {
showGetStarted()
showGetStarted(forWPComSite: true)
return
}

Expand All @@ -600,7 +600,7 @@ private extension SiteAddressViewController {

self.showWPUsernamePassword()
case .presentEmailController:
self.showGetStarted()
self.showGetStarted(forWPComSite: false)
case let .injectViewController(customUI):
self.pushCustomUI(customUI)
}
Expand Down Expand Up @@ -651,16 +651,16 @@ private extension SiteAddressViewController {

/// If the site is WordPressDotCom, redirect to WP login.
///
func showGetStarted() {
func showGetStarted(forWPComSite: Bool) {
guard let vc = GetStartedViewController.instantiate(from: .getStarted) else {
WPAuthenticatorLogError("Failed to navigate from SiteAddressViewController to GetStartedViewController")
return
}
vc.source = .wpComSiteAddress

vc.loginFields = loginFields
vc.dismissBlock = dismissBlock
vc.errorToPresent = errorToPresent
vc.wpcomSiteAddressDetected = forWPComSite

navigationController?.pushViewController(vc, animated: true)
}
Expand Down

0 comments on commit 08a25e9

Please sign in to comment.