fix(settings): Get email from account hook instead of location state#18157
fix(settings): Get email from account hook instead of location state#18157jonalmeida merged 1 commit intomainfrom
Conversation
| const account = useAccount(); | ||
| const { uid, sessionToken } = currentAccount() || {}; | ||
| // TODO: how do we properly handle the real non-null nature? | ||
| const { uid, sessionToken, email = '💩' } = currentAccount() || {}; |
There was a problem hiding this comment.
💩 🤣
currentAccount pulls from local storage right, which is what we want most of the time 👍 but just from a quick search, I only see us call storeAccountData in CompleteResetPassword so is this available from local storage at this point in the flow...? If not, then location state seems like maybe the correct place?
To hopefully answer the code comment question, before the return (<ResetPasswordWithRecoveryKeyVerified can we just check that these values are non-null and if so, redirect? See how we check for !email in the signin container component. (I don't think this is applicable here but if we ever have a case where we're passing non-null values into a component just to pass them back to a callback, we can curry them, see InlineRecoveryKeySetup and SetPassword containers)
FWIW related to your PR title, we shouldn't be using useAccount unless we want the entire GQL query to run, we've got a ticket to remove it in reset PW.
There was a problem hiding this comment.
This page is reached after CompleteResetPassword so email should be stored in local storage at this stage - if it isn't, that means the user isn't signed in and should likely be redirected to /signin
There was a problem hiding this comment.
Ah thanks Valerie, I can never keep these reset PW flows straight. So yeah, currentAccount is the right thing here and I think if the value is null we can just redirect to /signin as you said.
There was a problem hiding this comment.
Thanks for the discussion! I've updated the PR and had to rebase it on #18156 for now.
FWIW related to your PR title, we shouldn't be using useAccount unless we want the entire GQL query to run, we've got a ticket to remove it in reset PW.
Sorry, that was a typo - I meant currentAccount. This seems to be the right one that also accounts for the email that comes from a web channel message.
f8ba615 to
5ce908e
Compare
Because
This pull request
currentAccount.Issue that this pull request solves
Closes: FXA-10876
Checklist
Put an
xin the boxes that applyScreenshots (Optional)
n/a
Other information (Optional)
Built on top of #18136. Will rebase when the prior PR lands.