File tree Expand file tree Collapse file tree
packages/fxa-settings/src/pages/Signin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,7 +91,23 @@ import OAuthDataError from '../../components/OAuthDataError';
9191 */
9292
9393function 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 ,
You can’t perform that action at this time.
0 commit comments