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] Use magic link for suspicious emails #15444

Open
wants to merge 9 commits into
base: trunk
Choose a base branch
from

Conversation

hichamboushaba
Copy link
Member

@hichamboushaba hichamboushaba commented Mar 27, 2025

Closes: #15442

Description

This PR implements the first part of the project, updating the suspicious email flow to use magic links in the login.

In my spike initially, I suggested reusing the screen LoginLinkRequestViewController, but when working on this, I found out that this screen is not part of the unified login flow, so I added a new screen, and I matched its design to the Android one.

Steps to reproduce

TC1: Confirming navigation to magic link request screen

  1. Open the app.
  2. Enter the address of a Jetpack connected site
  3. Enter the email address shared here 37602-pb
  4. Make sure to not send the magic link.

For all the following TCs, apply the following patch

TC2: Magic Link login flow

  1. Open the app
  2. Enter the address of a Jetpack connected site.
  3. Enter an address email that can receive magic links
  4. Tap on Send email in the next screen.

TC3: Fallback to username/password

  1. Open the app
  2. Enter the address of a Jetpack connected site.
  3. Enter an address email that can receive magic links
  4. Tap on Use username and password instead.
  5. Sign in using site credentials.

Testing information

TC1: Confirm that the app shows the Magic Link request screen.

TC2: Confirm that the email was sent, and that the following was tracked:

🔵 Tracked unified_login_step, properties: [flow: login_magic_link, step: start, source: default]
🔵 Tracked login_magic_link_request_form_viewed
🔵 Tracked unified_login_interaction, properties: [source: default, flow: login_magic_link, step: start, click: request_magic_link]
🔵 Tracked unified_login_step, properties: [source: default, step: magic_link_auto_requested, flow: login_magic_link]

TC3: Confirm that signing using site credentials work, and that the following was tracked after tapping on the fallback button:

Tracked unified_login_step, properties: [flow: login_magic_link, source: default, step: start]
🔵 Tracked login_magic_link_request_form_viewed
🔵 Tracked unified_login_interaction, properties: [click: login_with_wp_com_username_password, source: default, step: start, flow: login_magic_link]

Screenshots

Simulator.Screen.Recording.-.iPhone.16.-.2025-03-28.at.01.56.28.mp4

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on all devices (phone/tablet) and no regressions are added.

@hichamboushaba hichamboushaba added type: enhancement A request for an enhancement. feature: login Related to any part of the log in or sign in flow, or authentication. labels Mar 27, 2025
Copy link

coderabbitai bot commented Mar 27, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dangermattic
Copy link
Collaborator

dangermattic commented Mar 27, 2025

1 Warning
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Mar 27, 2025

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Number29020
VersionPR #15444
Bundle IDcom.automattic.alpha.woocommerce
Commite033e5f
Installation URL6df3atnrh0m68
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@hichamboushaba hichamboushaba force-pushed the issue/14878-login-suspicious-email-p1 branch from 7eecc65 to 1102b53 Compare March 28, 2025 01:47
@hichamboushaba hichamboushaba force-pushed the issue/14878-login-suspicious-email-p1 branch from 1102b53 to f3ea590 Compare March 28, 2025 01:59

// MARK: UI Setup
private extension MagicLinkRequestViewController {
private func configureStackView() {
Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't use a xib file, as I still don't feel familiar with XCode UI for them, and I didn't use SwiftUI just to make sure the content is correctly styled to match the other screens. If you have any remarks about this please share them.

@hichamboushaba hichamboushaba added this to the 22.1 milestone Mar 28, 2025
@hichamboushaba hichamboushaba force-pushed the issue/14878-login-suspicious-email-p1 branch from f3ea590 to e033e5f Compare March 28, 2025 02:03
@hichamboushaba hichamboushaba marked this pull request as ready for review March 28, 2025 02:04
@selanthiraiyan selanthiraiyan self-assigned this Mar 28, 2025
Copy link
Contributor

@selanthiraiyan selanthiraiyan left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, Hicham! Great job navigating through the authenticator library code. 👏


I have a the following questions about the UI before approving this PR.

  1. Would the wording "store credentials" in the above screen create confusion about where to enter their store's wporg credentials or WPCOM username and password?
  2. I see that we pre-fill the email in the above screen. AFAIK, logging in using WPCOM email and password will not work for a suspicious email. Should we avoid pre-filling the email.

The title of "Use username and password instead" button isn't fully visible while using large fonts.

)
}

private func fallbackButtonTitle() -> String {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private func fallbackButtonTitle() -> String {
func fallbackButtonTitle() -> String {

nit: This method is already inside a private extension.

pinSubviewToHorizontalEdges(primaryButton)
}

private func createHeader() -> UIView {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We can remote the private keyword as this method is already inside a private extension. Applies to other methods inside this extension.

private func createHeader() -> UIView {
let headerStackView = UIStackView()
headerStackView.spacing = 16
headerStackView.layoutMargins = UIEdgeInsets(top: 24, left: 16, bottom: 24, right: 16)
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest moving the spacing and padding related constants used in this view inside a Layout enum like we follow in SwiftUI views. WDYT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: login Related to any part of the log in or sign in flow, or authentication. type: enhancement A request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Login] Use magic link for suspicious emails
4 participants