Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login: Auth Code Interface #1615

Merged
merged 21 commits into from
Jul 16, 2024
Merged

Login: Auth Code Interface #1615

merged 21 commits into from
Jul 16, 2024

Conversation

jleandroperez
Copy link
Contributor

@jleandroperez jleandroperez commented Jul 15, 2024

Details

In this PR we're:

  1. Extracting AuthenticationMode into its own file
  2. Updating the AuthViewController initialization, so that it uses dynamic descriptors
  3. Adding a new Code field
  4. And enhancing the Login Flow so that users can enter their Auth Code

Ref. #1611

Test: Login with Code

  1. Fresh install Simplenote
  2. Press on Log In
  3. Enter your email and press on Log in with email
  • Verify that entering a code shorter than 6 characters results in an error
  • Verify that entering an invalid code results in an error
  • Verify that if you enter the correct code, you get authenticated

Test: Login with Password

  1. Fresh install Simplenote
  2. Press on Log In
  3. Enter your email and press on Log in with email
  4. Press on Enter Password
  • Verify that pressing Log In gets you a warning onscreen
  • Verify that entering an incorrect password gets you a warning
  • Verify that entering your password gets you authenticated

Test: Login with WP

  1. Fresh install Simplenote
  2. Press on Log In
  3. Press on Log in with WordPress.com
  • Verify that the WPCOM SSO works as expected

Test: Signup

  1. Fresh install Simplenote
  2. Press on Signup
  • Verify that pressing on the ToS link gets you the ToS website
  • Verify that pressing Sign Up without entering a valid email gets you a warning onscreen
  • Verify that if you enter a valid email, you can complete the SignUp process

Release

These changes do not require release notes.

@jleandroperez jleandroperez self-assigned this Jul 15, 2024
@dangermattic
Copy link
Collaborator

dangermattic commented Jul 15, 2024

2 Warnings
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jul 15, 2024

You can test the changes in simplenote-ios from this Pull Request by:

  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr1615-7f59dfe-0190b81a-8d48-492e-bd20-54fdc07605ae on your iPhone

If you need access to App Center, please ask a maintainer to add you.

return false
}
}


// MARK: - State
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the structs below have been extracted + simplified into AuthenticationMode

@@ -850,50 +850,6 @@ private enum PasswordInsecureString {
}


// MARK: - Mode: .loginWithPassword
//
private enum PasswordStrings {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same note as above: extracted into AuthenticationMode

break
}

performPrimaryActionIfPossible()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

performPrimaryActionIfPossible is now responsible for rendering Warnings, when / if needed.

Plus we'll never show Username + Password fields, at once, so we're simplifying this

@@ -662,6 +756,7 @@ private extension SPAuthViewController {
func ensureWarningsAreOnScreenWhenNeeded() -> Bool {
let usernameValidationResult = performUsernameValidation()
let passwordValidationResult = performPasswordValidation()
let codeValidationResult = performCodeValidation()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extending pre-existant validation mechanisms, to check for the Code as well

SPTracker.trackLoginLinkConfirmationFailure()
self.handleError(error: error)
} catch {
// TODO: Fixme
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be revisited in a follow up:

  1. I'm not fond of not having typed errors
  2. I think rate limited responses should be handled in a specific way (ie. pushing the Password UI)

lockdownInterface()

controller.requestLoginEmail(username: email) { error in
// TODO: 429 (Rate Limited)? push PW auth instead
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be handled in a follow up. Rate limiting errors should prob. cause the Password UI to show up

@@ -332,16 +381,21 @@ private extension SPAuthViewController {

// MARK: - Actions
//
private extension SPAuthViewController {
extension SPAuthViewController {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing private since the AuthenticationMode descriptors live in its own file


actionView.addTarget(self, action: descriptor.selector, for: .touchUpInside)
actionView.isHidden = false
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we don't have 4x Actions, and use them accordingly. Instead, we should simply instantiate the UIButton instances, based on the descriptor.

I'm keeping the changeset delta on check, though, and following along. For now!


/// # Primary Action: LogIn / SignUp
///
@IBOutlet private var primaryActionButton: SPSquaredButton! {
didSet {
primaryActionButton.setTitle(mode.primaryActionText, for: .normal)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the UI initialization code that was deleted here, will be handled by the new API(s) refreshActionViews and reloadInputViewsFromState.

@jleandroperez jleandroperez changed the title [WIP] Login: Auth Code Interface Login: Auth Code Interface Jul 15, 2024
@jleandroperez jleandroperez added this to the 4.52 milestone Jul 15, 2024
@jleandroperez jleandroperez added the enhancement Improve existing functionality. label Jul 15, 2024
@jleandroperez jleandroperez marked this pull request as ready for review July 15, 2024 21:18

return usernameValidationResult == .success && passwordValidationResult == .success
return usernameValidationResult == .success && passwordValidationResult == .success && codeValidationResult == .success
Copy link
Contributor

@charliescheer charliescheer Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is duplicated in L192. Should it be extracted somewhere?

Copy link
Contributor

@charliescheer charliescheer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the auth view is much more complex now, but this does a good job of simplifying additions and changes.

Base automatically changed from lantean/1611-updates-auth-flow to trunk July 16, 2024 17:17
@jleandroperez
Copy link
Contributor Author

Yeahhhh I'm tempted to just start splitting (or even going SwiftUI), but with this approach we can add or remove things in a split second.

Adding Passkeys should take a minute, now?

Thank you Charlie!!

@jleandroperez jleandroperez merged commit d61bddc into trunk Jul 16, 2024
20 of 28 checks passed
@jleandroperez jleandroperez deleted the lantean/1611-login-code-ui branch July 16, 2024 17:19
@charliescheer charliescheer restored the lantean/1611-login-code-ui branch July 16, 2024 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve existing functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants