Skip to content

Commit df1ad84

Browse files
authored
Move using stored credentials prompt to the WP.com sign in flow (#23677)
1 parent d6c77da commit df1ad84

File tree

2 files changed

+20
-23
lines changed

2 files changed

+20
-23
lines changed

WordPressAuthenticator/Sources/Signin/LoginPrologueViewController.swift

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ class LoginPrologueViewController: LoginViewController {
3232
private let configuration = WordPressAuthenticator.shared.configuration
3333
private let style = WordPressAuthenticator.shared.style
3434

35-
private lazy var storedCredentialsAuthenticator = StoredCredentialsAuthenticator(onCancel: { [weak self] in
36-
// Since the authenticator has its own flow
37-
self?.tracker.resetState()
38-
})
39-
4035
/// We can't rely on `isMovingToParent` to know if we need to track the `.prologue` step
4136
/// because for the root view in an App, it's always `false`. We're relying this variiable
4237
/// instead, since the `.prologue` step only needs to be tracked once.
@@ -116,11 +111,6 @@ class LoginPrologueViewController: LoginViewController {
116111
} else {
117112
tracker.set(step: .prologue)
118113
}
119-
120-
// Only enable auto fill if WPCom login is available
121-
if configuration.enableSiteAddressLoginOnlyInPrologue == false {
122-
showiCloudKeychainLoginFlow()
123-
}
124114
}
125115

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

146-
// MARK: - iCloud Keychain Login
147-
148-
/// Starts the iCloud Keychain login flow if the conditions are given.
149-
///
150-
private func showiCloudKeychainLoginFlow() {
151-
guard WordPressAuthenticator.shared.configuration.enableUnifiedAuth,
152-
let navigationController = navigationController else {
153-
return
154-
}
155-
156-
storedCredentialsAuthenticator.showPicker(from: navigationController)
157-
}
158-
159136
private func configureButtonVC() {
160137
guard configuration.enableUnifiedAuth else {
161138
buildPrologueButtons()

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ class GetStartedViewController: LoginViewController, NUXKeyboardResponder {
8888

8989
private var passwordCoordinator: PasswordCoordinator?
9090

91+
private lazy var storedCredentialsAuthenticator = StoredCredentialsAuthenticator(onCancel: { [weak self] in
92+
// Since the authenticator has its own flow
93+
self?.tracker.resetState()
94+
})
95+
9196
/// Sign in with site credentials button will be displayed based on the `screenMode`
9297
///
9398
private var screenMode: ScreenMode {
@@ -181,6 +186,21 @@ class GetStartedViewController: LoginViewController, NUXKeyboardResponder {
181186
registerForKeyboardEvents(keyboardWillShowAction: #selector(handleKeyboardWillShow(_:)),
182187
keyboardWillHideAction: #selector(handleKeyboardWillHide(_:)))
183188
}
189+
190+
if screenMode == .signInUsingWordPressComOrSocialAccounts && isMovingToParent {
191+
showiCloudKeychainLoginFlow()
192+
}
193+
}
194+
195+
/// Starts the iCloud Keychain login flow if the conditions are given.
196+
///
197+
private func showiCloudKeychainLoginFlow() {
198+
guard WordPressAuthenticator.shared.configuration.enableUnifiedAuth,
199+
let navigationController = navigationController else {
200+
return
201+
}
202+
203+
storedCredentialsAuthenticator.showPicker(from: navigationController)
184204
}
185205

186206
override func viewWillDisappear(_ animated: Bool) {

0 commit comments

Comments
 (0)