-
Notifications
You must be signed in to change notification settings - Fork 212
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
base: main
Are you sure you want to change the base?
Conversation
packages/fxa-settings/src/pages/InlineRecoveryKeySetup/container.tsx
Outdated
Show resolved
Hide resolved
return <></>; | ||
} | ||
|
||
// Curry already checked values |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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.
There was a problem hiding this 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, |
There was a problem hiding this comment.
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" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
export const MAX_HINT_LENGTH = 255; | ||
|
||
export const RecoveryKeySetupHint = ({ |
There was a problem hiding this comment.
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.
packages/fxa-settings/src/pages/InlineRecoveryKeySetup/container.tsx
Outdated
Show resolved
Hide resolved
const sensitiveDataClient = useSensitiveDataClient(); | ||
const sensitiveData = sensitiveDataClient.getData(AUTH_DATA_KEY); | ||
const { authPW, emailForAuth } = | ||
(sensitiveData as unknown as { emailForAuth: string; authPW: string }) || |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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
.
There was a problem hiding this 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( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.' |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
f9aae41
to
9a4196f
Compare
…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
Because:
This commit:
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.