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

feat(recovery-key): Make inline recovery key flow functional + navigate desktop Sync signins #17629

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LZoog
Copy link
Contributor

@LZoog LZoog commented Sep 18, 2024

Because:

  • We want to encourage Sync signin users to create an account recovery key

This commit:

  • Moves and refactors part of FlowRecoveryKeyHint into new component for sharing
  • Sets ups the create recovery key and hint handlers in container component, call where needed
  • Queries if recovery key exists after signin if sync, stores PW-related data into sensitiveDataClient
  • Navigates signing in desktop Sync flow users without a recovery key to this new flow before taking them to CAD, if the feature flag is on

closes FXA-10079


Create an account, and then through the Sync flow / fxa-dev-launcher, sign in. If the account doesn't have a recovery key, you'll be taken to the new flow after 2FA/signin token code. Double check me that sync sign in is as expected for all cases, it seems to be from my testing.

At the end of the flow users are then taken to CAD without the "You're signed into Firefox" success messaging. We are making modifications to CAD in another ticket this sprint, so we may need a follow up issue after that to display "Recovery key hint saved" or some similar success messaging on the pair choice screen, but that's TBD and Eduardo gave the thumbs up on this for now.

return <></>;
}

// Curry already checked values
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a few places in other container components I think we could benefit from doing this in. This avoids having to pass these values into InlineRecoveryKeySetup and avoids having to tell typescript with ! that these are not undefined.

Copy link
Contributor

Choose a reason for hiding this comment

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

Very nice 🙌 Also simplifies a lot of the mocking for tests and stories

// taken to signin_token_code, else GQL responds with 'Invalid token'

// todo: add try/catch
const { exists } = await authClient.recoveryKeyExists(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think Sync users always go to signin_token_code or the 2FA page if they have 2FA, but I’ve gotten myself into a state locally where I didn’t have to enter the code just the other day, so it was either this or pass the authClient function from the 3 container components down into the presentation component and into handleNavigation to call there.

It was easiest to just call here but with this approach the session token isn't verified yet. Alternatively I could have returned this value at the signIn mutation which I started to do at first since I could check if input.options.service === 'sync', but... it felt wrong returning a value like that in the mutation since I didn't see where we were doing something like that otherwise. (LMK if you disagree just so I know for the future.)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is fine the way you have it here. New users who just connected a new device would not have to enter an email code and would then get prompted to setup recovery key.

Copy link
Contributor Author

@LZoog LZoog left a comment

Choose a reason for hiding this comment

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

Did a little self-review, this is fully testable but the next push should have more unit tests and a rebase on latest main.

@@ -88,7 +88,7 @@ export const DataBlock = ({
) : (
<span
className={classNames({
'flex flex-col self-center align-middle grow pe-4': isInline,
'flex flex-col self-center align-middle grow': isInline,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes the recovery key dropping to two lines.

const spinner = (
<LoadingSpinner className="bg-grey-20 flex items-center flex-col justify-center h-screen select-none" />
<LoadingSpinner className="bg-grey-20 flex items-center flex-col justify-center select-none" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes:
image


export const MAX_HINT_LENGTH = 255;

export const RecoveryKeySetupHint = ({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A large chunk of this was moved from FlowRecoveryKeyHint and tweaked to work with both page components. I left the flow metrics/viewName stuff as-is.

I did modify the top/bottom padding of LightbulbImage though, it was too much space based on both Figmas.

const sensitiveDataClient = useSensitiveDataClient();
const sensitiveData = sensitiveDataClient.getData(AUTH_DATA_KEY);
const { authPW, emailForAuth } =
(sensitiveData as unknown as { emailForAuth: string; authPW: string }) ||
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we could make some solid improvements with this, and move other values to it. I'll file a follow up and put it in our React Cleanup epic if we don't have something filed already, or leave a note on the React state management spike.

'data' in result &&
result.data &&
options.service === 'sync'
// && localStorage.getItem('TODO')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently tweaking this. Instead of having this check in getSyncNavigate too, I'm just going to do it here only and rename result.data.recoveryKeyExists.

Copy link
Contributor

@vbudhram vbudhram left a comment

Choose a reason for hiding this comment

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

@LZoog This is great! I've done a first pass of the code and tested it locally, which all seems to be working as expected.

I haven't verified metrics yet but I think that might be ok as a quick follow up since the PR is pretty big as it is.

expect(accountWithSuccess.updateRecoveryKeyHint).toBeCalledWith(
hintValue
);
expect(logViewEvent).toBeCalledWith(
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we stopped supporting the older metrics in new views?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! But most of this component was re-used from previous implementation so I left these.

} else if (!DISPLAY_SAFE_UNICODE.test(hint)) {
const localizedUnsafeUnicodeCharError = ftlMsgResolver.getMsg(
'flow-recovery-key-hint-unsafe-char-error',
'The hint cannot contain unsafe unicode characters. Only letters, numbers, punctuation marks and symbols are allowed.'
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏽

// taken to signin_token_code, else GQL responds with 'Invalid token'

// todo: add try/catch
const { exists } = await authClient.recoveryKeyExists(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is fine the way you have it here. New users who just connected a new device would not have to enter an email code and would then get prompted to setup recovery key.

@LZoog LZoog marked this pull request as ready for review September 19, 2024 20:13
@LZoog LZoog requested review from a team as code owners September 19, 2024 20:13
@LZoog LZoog force-pushed the FXA-10079 branch 3 times, most recently from f9aae41 to 9a4196f Compare September 19, 2024 21:18
…te desktop Sync signins

Because:
* We want to encourage Sync signin users to create an account recovery key

This commit:
* Moves and refactors part of FlowRecoveryKeyHint into new component for sharing
* Sets ups the create recovery key and hint handlers in container component, call where needed
* Queries if recovery key exists after signin if sync, stores PW-related data into sensitiveDataClient
* Navigates signing in desktop Sync flow users without a recovery key to this new flow before taking them to CAD, if the feature flag is on

closes FXA-10079
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.

4 participants