@@ -65,14 +65,11 @@ const LoggedInHandler = (() => {
6565 // Clear all accounts before entering the loop
6666 Client . clearAllAccounts ( ) ;
6767
68- let is_loginid_set = false ;
6968 account_list . forEach ( ( account ) => {
7069 Object . keys ( account ) . forEach ( ( param ) => {
7170 if ( param === 'loginid' ) {
72- if ( ! is_loginid_set && ! account . is_virtual &&
73- ! account . is_disabled ) {
71+ if ( ! Client . get ( 'loginid' ) && ! account . is_virtual && ! account . is_disabled ) {
7472 Client . set ( param , account [ param ] ) ;
75- is_loginid_set = true ;
7673 }
7774 } else {
7875 const param_to_set = map_names [ param ] || param ;
@@ -82,12 +79,6 @@ const LoggedInHandler = (() => {
8279 } ) ;
8380 } ) ;
8481
85- // if didn't find any login ID that matched the above condition, set the first one at the end of the loop
86- if ( ! is_loginid_set ) {
87- Client . set ( 'loginid' , params . acct1 || account_list [ 0 ] . loginid ) ;
88- is_loginid_set = true ;
89- }
90-
9182 let i = 1 ;
9283 while ( params [ `acct${ i } ` ] ) {
9384 const loginid = params [ `acct${ i } ` ] ;
@@ -98,6 +89,12 @@ const LoggedInHandler = (() => {
9889 i ++ ;
9990 }
10091
92+ // if didn't find any login ID that matched the above condition
93+ // or the selected one doesn't have a token, set the first one
94+ if ( ! Client . get ( 'loginid' ) || ! Client . get ( 'token' ) ) {
95+ Client . set ( 'loginid' , params . acct1 || account_list [ 0 ] . loginid ) ;
96+ }
97+
10198 if ( Client . isLoggedIn ( ) ) {
10299 GTM . setLoginFlag ( ) ;
103100 Client . set ( 'session_start' , parseInt ( moment ( ) . valueOf ( ) / 1000 ) ) ;
0 commit comments