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

Fixed getting two magic codes upon signing in once #30849

Conversation

samilabud
Copy link
Contributor

@samilabud samilabud commented Nov 3, 2023

Details

When the user account has SAML enabled and tries to login, the application sends the magic code(like when the user does not have SAML enabled) and displays a form for the user indicating that must select how to be authenticated if using a single sign-on or using magic code, at this point the user has a magic code in the mail but can't be used, so if the user selects the magic code authentication then he will get a second code.

Fixed Issues

$ #30181
PROPOSAL: #30181 (comment)

Tests

  1. Login with a user that has SAML access (currently I'm forcing this in SignInPage) to test.
  2. UI should show the Single SignOn form and Magic Code form
  3. One magic code should be in your mail
  4. Enter the magic code that you just received
  5. Should be logged in successfully
  6. Verify again there is no new magic code in your email
  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

  1. Login with a user that has SAML access like [email protected] to test.
  2. UI should show the Single SignOn form and Magic Code form
  3. One magic code should be in your mail
  4. Enter the magic code that you just received
  5. Should be logged in successfully
  6. Verify again there is no new magic code in your email
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • If we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes
      • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native

N/A

Single SignOn is only available for web and mweb, see this comment:
https://github.com/Expensify/App/blob/f9eef5480013c7b99340b18e9621edc5a8bf5fbc/src/pages/signin/SignInPage.js#L102

Android: mWeb Chrome
UX.Manual.Test.Chrome.Android.reduced.mp4
iOS: Native

Single SignOn is only available for web and mweb, see this comment:
https://github.com/Expensify/App/blob/f9eef5480013c7b99340b18e9621edc5a8bf5fbc/src/pages/signin/SignInPage.js#L102

iOS: mWeb Safari
UX.Manual.Test.Safari.Iphone.15.mp4
MacOS: Chrome / Safari
UX.Manual.Test.Chrome.Web.reduced.mp4
MacOS: Desktop
UX.Manual.Test.Mac.Desktop.reduced.mp4

@samilabud samilabud requested a review from a team as a code owner November 3, 2023 14:11
@melvin-bot melvin-bot bot requested review from robertKozik and removed request for a team November 3, 2023 14:11
Copy link

melvin-bot bot commented Nov 3, 2023

@robertKozik Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@robertKozik
Copy link
Contributor

Hi @samilabud can you add to the test steps to verify that only one magic code is being sent? It was the main problem of the issue so we should include it in test steps

@samilabud
Copy link
Contributor Author

Of course, is there any similar test that I can see?

@robertKozik
Copy link
Contributor

Actually I was thinking about adding additional step, to the ones you have, like "verify that only one magic code..."

@samilabud
Copy link
Contributor Author

Oh sorry, I was thinking of some unit test using JEST/RTL 😅, I have added this full test in the proposal before, please confirm if this is what you are requesting:

After.changes.reduced.mp4

@robertKozik
Copy link
Contributor

Looks we are still not exactly on the same page 😄 In the first comment you have Test Steps, there please add additional step - something like: verify that only one mail with magic code is being sent

@samilabud
Copy link
Contributor Author

Oh my bad, sorry!
done!

@robertKozik
Copy link
Contributor

Thanks! Will review the code today

@samilabud
Copy link
Contributor Author

Thanks! Will review the code today

Hey, were you able to review it?

@robertKozik
Copy link
Contributor

yeah right, sorry it slipped through the cracks :( Could you resolve conflicts? I would prioritise reviewing it

@samilabud samilabud force-pushed the getting_two_magic_codes_upon_signing_once_30181 branch from f9eef54 to 88ead66 Compare November 22, 2023 13:35
@samilabud
Copy link
Contributor Author

yeah right, sorry it slipped through the cracks :( Could you resolve conflicts? I would prioritise reviewing it

Done, thanks!

@samilabud samilabud force-pushed the getting_two_magic_codes_upon_signing_once_30181 branch from d47d043 to 88ead66 Compare November 22, 2023 14:35
@robertKozik
Copy link
Contributor

BUG: Error information for magic code is duplicated

image

@robertKozik
Copy link
Contributor

BUG: After clicking one button, both of them get into loading state

image

@samilabud
Copy link
Contributor Author

BUG: Error information for magic code is duplicated

image
Fixed duplicated error

@samilabud
Copy link
Contributor Author

BUG: After clicking one button, both of them get into loading state

image
Fixed.both.loading.state.mp4

@samilabud samilabud force-pushed the getting_two_magic_codes_upon_signing_once_30181 branch from 88ead66 to e9e5bd3 Compare November 23, 2023 19:20
@samilabud
Copy link
Contributor Author

@robertKozik I believe I addressed all scenarios, please check again. 🙏🏼

@robertKozik
Copy link
Contributor

I'm still encountering problems while account has enabled 2FA. After typing magic link, the text does not changing accordingly when user needs to type authenticator code/recovery code. Can we render the proper section after user typed magic code?

@samilabud
Copy link
Contributor Author

I'm still encountering problems while account has enabled 2FA. After typing magic link, the text does not changing accordingly when user needs to type authenticator code/recovery code. Can we render the proper section after user typed magic code?

Hey, could you please share an example regarding text not changing accordingly? Also, what does means proper section in this case? I was doing a test to compare the normal use of magic code and our change and I don't see differences:

Normal use:

Render.magic.code.as.normal.mp4

Our change:

Render.proper.section.two.magic.codes.mp4

@robertKozik
Copy link
Contributor

... while account has enabled 2FA. ...

On settings you can enable 2FA (two factor authentication) - while this is enabled after providing magic code, user is obligated to input authenticaton code from external app

@samilabud samilabud force-pushed the getting_two_magic_codes_upon_signing_once_30181 branch from e9e5bd3 to 5a34702 Compare November 24, 2023 19:25
@samilabud
Copy link
Contributor Author

... while account has enabled 2FA. ...

On settings you can enable 2FA (two factor authentication) - while this is enabled after providing magic code, user is obligated to input authenticaton code from external app

Good catch!, my bad I didn't know that, is fixed now:

Fixed.two.factor.auth.Two.Magic.Codes.mp4

Thank you!

@robertKozik
Copy link
Contributor

Im still seeing the same text mentioning magic code, even when user needs to type authenticator code.
image

@samilabud samilabud force-pushed the getting_two_magic_codes_upon_signing_once_30181 branch from 5a34702 to 33af388 Compare November 28, 2023 00:27
@samilabud
Copy link
Contributor Author

@samilabud The margin bottom of the animation on the initial login screen is definitely off. Please fix this.

Screen.Recording.2024-04-10.at.3.32.42.PM.mov

I'm trying to check it, but I'm getting this error when making a build: https://expensify.slack.com/archives/C01GTK53T8Q/p1712782954992479, I let you know when I can fix it 🤓.

@samilabud
Copy link
Contributor Author

Hi team, please verify again:

Test.Two.Magic.code.mp4

@madmax330
Copy link
Contributor

@samilabud it looks like it's failing lint test

@samilabud
Copy link
Contributor Author

Thank you @madmax330, it fixed now, please verify 🙏🏼.

@allroundexperts
Copy link
Contributor

Hi @samilabud!

This is now broken again for the case where SAML is enabled.

Screen.Recording.2024-04-15.at.5.28.31.PM.mov

Instead of just pushing the code changes, can you please make sure that the animation works on all three screens (normal login and SSO enabled login)? Thanks!

@samilabud
Copy link
Contributor Author

Hi @samilabud!

This is now broken again for the case where SAML is enabled.

Screen.Recording.2024-04-15.at.5.28.31.PM.mov
Instead of just pushing the code changes, can you please make sure that the animation works on all three screens (normal login and SSO enabled login)? Thanks!

Hi, thanks for testing this, sorry for the inconvenience, could you share with me what version of android and resolution you are testing, it seems to be doing fine on Pixel 7 pro (1440x3120):

SAML Enabled:

Screen.Recording.2024-04-15.at.9.02.14.AM.mov

Normal Login:

Screen.Recording.2024-04-15.at.9.09.51.AM.mov

@allroundexperts
Copy link
Contributor

I was testing on Chrome with mobile mode enabled.

@samilabud
Copy link
Contributor Author

I was testing on Chrome with mobile mode enabled.

Nice this made me see that it was not necessary to have the height of the parent component fixed, these were my tests, please let me know if you see it right:

Android Chrome - SAML Enabled:

Android.Chrome.-.SAML.Enabled.mov

Android Chrome - SAML Not Enabled

Android.Chrome.-.SAML.Not.Enabled.mov

Android Native - SAML Enabled

Android.Native.-.SAML.Enabled.mov

Android Native - SAML Not Enabled

Android.Native.-.SAML.Not.Enabled.mov

MAC Chrome - Responsive SAML Enabled

MAC.Chrome.-.Responsive.SAML.Enabled.mp4

MAC Chrome - Responsive SAML Not Enabled

MAC.Chrome.-.Responsive.SAML.Not.Enabled.mp4

@allroundexperts
Copy link
Contributor

Looks good now. Thanks for the thorough testing!

@melvin-bot melvin-bot bot requested a review from madmax330 April 15, 2024 14:07
@madmax330
Copy link
Contributor

@allroundexperts @robertKozik Looks like the PR reviewer checklist was never completed

@allroundexperts
Copy link
Contributor

@madmax330 It's complete. You need to delete the incomplete checklist from Robert.

@Expensify Expensify deleted a comment from robertKozik Apr 16, 2024
@madmax330 madmax330 merged commit b16aed0 into Expensify:main Apr 16, 2024
15 of 16 checks passed
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/madmax330 in version: 1.4.63-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 1.4.63-21 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@samilabud samilabud deleted the getting_two_magic_codes_upon_signing_once_30181 branch April 29, 2024 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants