Skip to content

[HOLD for payment 2024-02-26] [$500] Add support for redirecting user to a target URL(via exitTo query param) when they click on the magic link code #36325

Description

@techievivek

Part of #34166

Please go through the description of the above issue carefully before you post any questions.

We aim to enhance user experience by allowing first-time users to directly access our product feature without a need to manually go through the login process. This enhancement involves embedding a magic code in the offline activity email sent to users.

Magic Link Format: https://new.expensify.com/v//?exitTo=valid_target_path_in_newDot
https://new.expensify.com/v/123/000000?exitTo=r/12345

Functional Requirements:

  1. If the user is not logged in, the magic code should trigger the sign-in process automatically and redirect the user to the target URL specified in the exitTo parameter of the link once the sign-in logic is successfully executed.

  2. If the user is already logged in, the magic code sign-in should be skipped, and the user should be directly redirected to the exitTo URL.

Resources:
You will probably need to play with ValidateLoginPage logic
Website file: https://github.com/Expensify/App/blob/main/src/pages/ValidateLoginPage/index.website.tsx
Other platform: https://github.com/Expensify/App/blob/main/src/pages/ValidateLoginPage/index.tsx

Let me know if anything is unclear or if you need help with anything. Thanks.

CC @MitchExpensify

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01a6d9657733b55abf
  • Upwork Job ID: 1757021871380135936
  • Last Price Increase: 2024-02-12
  • Automatic offers:
    • rayane-djouah | Contributor | 0

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Feb 12, 2024
  2. self-assigned this
    on Feb 12, 2024
  3. melvin-bot commented on Feb 12, 2024

    @melvin-bot

    Triggered auto assignment to @bfitzexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  4. changed the title [-]Add support for redirecting user to a target URL(via exitTo query param) when they are already logged in and click on a deep link with magic code[/-] [+]Add support for redirecting user to a target URL(via exitTo query param) when they click on the magic link code[/+] on Feb 12, 2024
  5. added
    ExternalAdded to denote the issue can be worked on by a contributor
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 12, 2024
  6. melvin-bot commented on Feb 12, 2024

    @melvin-bot
  7. changed the title [-]Add support for redirecting user to a target URL(via exitTo query param) when they click on the magic link code[/-] [+][$500] Add support for redirecting user to a target URL(via exitTo query param) when they click on the magic link code[/+] on Feb 12, 2024
  8. melvin-bot commented on Feb 12, 2024

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @allroundexperts (External)

  9. abzokhattab commented on Feb 12, 2024

    @abzokhattab
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Add support for redirecting user to a target URL(via exitTo query param) when they click on the magic link code

    What is the root cause of that problem?

    new feature

    What changes do you think we should make in order to solve the problem?

    we need to modify the follwoing useEffect to check if the exitTo is present then it will navigate to it instead of the goBack

    useEffect(() => {
    // Wait till navigation becomes available
    Navigation.isNavigationReady().then(() => {
    if (session?.authToken) {
    // If already signed in, do not show the validate code if not on web,
    // because we don't want to block the user with the interstitial page.
    Navigation.goBack();
    } else {
    Session.signInWithValidateCodeAndNavigate(Number(accountID), validateCode);
    }
    });
    // eslint-disable-next-line react-hooks/exhaustive-deps
    }, []);

    additionaly we need to add another param exitTo in the signInWithValidateCodeAndNavigate function

    function signInWithValidateCodeAndNavigate(accountID: number, validateCode: string, twoFactorAuthCode = '') {
    signInWithValidateCode(accountID, validateCode, twoFactorAuthCode);
    Navigation.navigate(ROUTES.HOME);
    }
    and use it in the navigation:

    function signInWithValidateCodeAndNavigate(accountID: number, validateCode: string, twoFactorAuthCode = '', exitTo = ROUTES.HOME) {
        signInWithValidateCode(accountID, validateCode, twoFactorAuthCode);
        Navigation.navigate(exitTo);
    }
  10. rayane-d commented on Feb 12, 2024

    @rayane-d
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Add support for redirecting user to a target URL(via exitTo query param) when they click on the magic link code

    What is the root cause of that problem?

    New feature

    What changes do you think we should make in order to solve the problem?

    we should add the new exitTo param here:

    [SCREENS.VALIDATE_LOGIN]: {
    accountID: string;
    validateCode: string;
    };

    and here:
    route: {
    params: {accountID, validateCode},
    },

    and here:

    params: {accountID, validateCode},

    we should check if an exitTo param is provided, in this case, we should navigate to it. here, and here.
    for native, we should replace here signInWithValidateCodeAndNavigate with signInWithValidateCode and check if an exitTo param is provided, in this case, we should navigate to it, here, and here.

    here is a draft PR with code changes for testing : #36390

    here is the result recordings:

    If the user is not logged in (and initiated the login process on the same browser)
    1.Recording.2024-02-13.015036.mp4
    If the user is not logged in (and initiated the login process in another browser)
    3.Recording.2024-02-13.015229.mp4
    If the user is already logged in
    2.Recording.2024-02-13.015620.mp4

    What alternative solutions did you explore? (Optional)

    N/A

  11. techievivek commented on Feb 12, 2024

    @techievivek
    ContributorAuthor

    I was already playing with changes similar to above, can you please add a branch for testing in your proposal, thanks.

  12. 25 remaining items

  13. techievivek commented on Feb 22, 2024

    @techievivek
    ContributorAuthor

    @rayane-djouah Another improvement that we can make here is that the magic code page appears for a moment. QA team shared this video.

    306718766-3c0f57f0-a683-4849-a2c3-4ea77b84d505.mp4

    Can you look into it and see if we can improve this.

  14. MitchExpensify commented on Feb 23, 2024

    @MitchExpensify
    Contributor

    Reminder set to pay

  15. bfitzexpensify commented on Feb 27, 2024

    @bfitzexpensify
    Contributor

    @techievivek just checking in on your comment here - do you consider this a regression from the solution used in this issue?

  16. techievivek commented on Feb 27, 2024

    @techievivek
    ContributorAuthor

    No, we can't classify it as a regression because it doesn't cause any general breakage. It would simply contribute to a smoother transition.

  17. bfitzexpensify commented on Feb 27, 2024

    @bfitzexpensify
    Contributor

    Gotcha, thanks for clarifying.

    Payment summary:

    C+: $500 to be paid to @allroundexperts through NewDot Manual Requests
    Contributor: $500 to be paid to @rayane-djouah via Upwork - complete ✅

    @allroundexperts, a reminder to complete the BZ checklist when you get a chance - thanks!

  18. bfitzexpensify commented on Mar 4, 2024

    @bfitzexpensify
    Contributor

    Bump on the BZ checklist @allroundexperts - thank you!

  19. allroundexperts commented on Mar 6, 2024

    @allroundexperts
    Contributor

    @bfitzexpensify This is a new feature and checklist isn't needed here.

  20. bfitzexpensify commented on Mar 6, 2024

    @bfitzexpensify
    Contributor

    Cool - closing this out. Thanks everyone!

  21. JmillsExpensify commented on Mar 12, 2024

    @JmillsExpensify
    Contributor

    $500 approved for @allroundexperts based on summary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in review

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions