Skip to content

Commit

Permalink
Move using stored credentials prompt to the WP.com sign in flow (#23677)
Browse files Browse the repository at this point in the history
  • Loading branch information
crazytonyli authored Nov 3, 2024
1 parent d6c77da commit df1ad84
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ class LoginPrologueViewController: LoginViewController {
private let configuration = WordPressAuthenticator.shared.configuration
private let style = WordPressAuthenticator.shared.style

private lazy var storedCredentialsAuthenticator = StoredCredentialsAuthenticator(onCancel: { [weak self] in
// Since the authenticator has its own flow
self?.tracker.resetState()
})

/// We can't rely on `isMovingToParent` to know if we need to track the `.prologue` step
/// because for the root view in an App, it's always `false`. We're relying this variiable
/// instead, since the `.prologue` step only needs to be tracked once.
Expand Down Expand Up @@ -116,11 +111,6 @@ class LoginPrologueViewController: LoginViewController {
} else {
tracker.set(step: .prologue)
}

// Only enable auto fill if WPCom login is available
if configuration.enableSiteAddressLoginOnlyInPrologue == false {
showiCloudKeychainLoginFlow()
}
}

override func viewWillDisappear(_ animated: Bool) {
Expand All @@ -143,19 +133,6 @@ class LoginPrologueViewController: LoginViewController {
setButtonViewMargins(forWidth: size.width)
}

// MARK: - iCloud Keychain Login

/// Starts the iCloud Keychain login flow if the conditions are given.
///
private func showiCloudKeychainLoginFlow() {
guard WordPressAuthenticator.shared.configuration.enableUnifiedAuth,
let navigationController = navigationController else {
return
}

storedCredentialsAuthenticator.showPicker(from: navigationController)
}

private func configureButtonVC() {
guard configuration.enableUnifiedAuth else {
buildPrologueButtons()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ class GetStartedViewController: LoginViewController, NUXKeyboardResponder {

private var passwordCoordinator: PasswordCoordinator?

private lazy var storedCredentialsAuthenticator = StoredCredentialsAuthenticator(onCancel: { [weak self] in
// Since the authenticator has its own flow
self?.tracker.resetState()
})

/// Sign in with site credentials button will be displayed based on the `screenMode`
///
private var screenMode: ScreenMode {
Expand Down Expand Up @@ -181,6 +186,21 @@ class GetStartedViewController: LoginViewController, NUXKeyboardResponder {
registerForKeyboardEvents(keyboardWillShowAction: #selector(handleKeyboardWillShow(_:)),
keyboardWillHideAction: #selector(handleKeyboardWillHide(_:)))
}

if screenMode == .signInUsingWordPressComOrSocialAccounts && isMovingToParent {
showiCloudKeychainLoginFlow()
}
}

/// Starts the iCloud Keychain login flow if the conditions are given.
///
private func showiCloudKeychainLoginFlow() {
guard WordPressAuthenticator.shared.configuration.enableUnifiedAuth,
let navigationController = navigationController else {
return
}

storedCredentialsAuthenticator.showPicker(from: navigationController)
}

override func viewWillDisappear(_ animated: Bool) {
Expand Down

0 comments on commit df1ad84

Please sign in to comment.