Skip to content

Commit a26c695

Browse files
authored
Merge pull request #18988 from mozilla/fix-error-on-signin-with-multiple-accounts
Fix error on signin with multiple accounts
2 parents 930b886 + d61d6f3 commit a26c695

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

packages/fxa-settings/src/pages/Signin/container.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,23 @@ import OAuthDataError from '../../components/OAuthDataError';
9191
*/
9292

9393
function getAccountInfo(email?: string) {
94-
const storedLocalAccount = currentAccount() || lastStoredAccount();
94+
95+
const storedLocalAccount = (() => {
96+
let account = currentAccount();
97+
if (account) {
98+
return account;
99+
}
100+
101+
// Important, a lot of the code following this assumes that if a session
102+
// token is provided, it belongs to the current account. If this assumption
103+
// is violated, weird things happen! Maybe this is the 'fix'?
104+
account = lastStoredAccount();
105+
if (account) {
106+
setCurrentAccount(account.uid);
107+
}
108+
109+
return account;
110+
})();
95111

96112
if (email) {
97113
// Try to use local storage values if email matches the email in local storage
@@ -107,7 +123,6 @@ function getAccountInfo(email?: string) {
107123
}
108124

109125
if (storedLocalAccount) {
110-
setCurrentAccount(storedLocalAccount.uid);
111126
return {
112127
email: storedLocalAccount.email,
113128
sessionToken: storedLocalAccount.sessionToken,

0 commit comments

Comments
 (0)