@@ -118,9 +118,11 @@ class AuthHandler {
118118 if ( result . user ) {
119119 log . debug ( 'Login successful, user found' , { module : 'auth-handler' , userEmail : result . user . email } ) ;
120120 resolve ( result . user as User ) ;
121- } else if ( result . error_code === 294 ) {
121+ }
122+ } )
123+ . catch ( async ( error : any ) => {
124+ if ( error . errorCode === 294 ) {
122125 const tfToken = await this . handleOTPFlow ( tfaToken , loginPayload ) ;
123-
124126 try {
125127 resolve ( await this . login ( email , password , tfToken ) ) ;
126128 } catch ( error ) {
@@ -129,14 +131,12 @@ class AuthHandler {
129131 reject ( error ) ;
130132 }
131133 } else {
132- log . debug ( 'Login failed: no user found.' , { module : 'auth-handler' , result } ) ;
134+ log . debug ( 'Login failed: no user found.' , { module : 'auth-handler' , error } ) ;
133135 reject ( new Error ( messageHandler . parse ( 'CLI_AUTH_LOGIN_NO_USER' ) ) ) ;
136+ log . debug ( 'Login API call failed.' , { module : 'auth-handler' , error : error ?. errorMessage || error } ) ;
137+ cliux . print ( 'CLI_AUTH_LOGIN_FAILED' , { color : 'yellow' } ) ;
138+ handleAndLogError ( error , { module : 'auth-handler' } ) ;
134139 }
135- } )
136- . catch ( ( error : any ) => {
137- log . debug ( 'Login API call failed.' , { module : 'auth-handler' , error : error ?. errorMessage || error } ) ;
138- cliux . print ( 'CLI_AUTH_LOGIN_FAILED' , { color : 'yellow' } ) ;
139- handleAndLogError ( error , { module : 'auth-handler' } ) ;
140140 } ) ;
141141 } else {
142142 const hasEmail = ! ! email ;
0 commit comments