@@ -118,26 +118,25 @@ 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 {
122- log . debug ( 'Login failed: no user found.' , { module : 'auth-handler' , result } ) ;
123- reject ( new Error ( messageHandler . parse ( 'CLI_AUTH_LOGIN_NO_USER' ) ) ) ;
124- }
125- } )
126- . catch ( async ( error : any ) => {
127- if ( error . errorCode === 294 ) {
121+ } else if ( result . error_code === 294 ) {
122+ const tfToken = await this . handleOTPFlow ( tfaToken , loginPayload ) ;
123+
128124 try {
129- const tfToken = await this . handleOTPFlow ( tfaToken , loginPayload ) ;
130125 resolve ( await this . login ( email , password , tfToken ) ) ;
131126 } catch ( error ) {
132127 log . debug ( 'Login with TFA token failed.' , { module : 'auth-handler' , error } ) ;
133128 cliux . print ( 'CLI_AUTH_2FA_FAILED' , { color : 'red' } ) ;
134129 reject ( error ) ;
135130 }
136131 } else {
137- log . debug ( 'Login API call failed.' , { module : 'auth-handler' , error : error ?. errorMessage || error } ) ;
138- cliux . print ( 'CLI_AUTH_LOGIN_FAILED' , { color : 'yellow' } ) ;
139- reject ( error ) ;
132+ log . debug ( 'Login failed: no user found.' , { module : 'auth-handler' , result } ) ;
133+ reject ( new Error ( messageHandler . parse ( 'CLI_AUTH_LOGIN_NO_USER' ) ) ) ;
140134 }
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' } ) ;
141140 } ) ;
142141 } else {
143142 const hasEmail = ! ! email ;
@@ -204,7 +203,7 @@ class AuthHandler {
204203 . catch ( ( error : Error ) => {
205204 log . debug ( 'Token validation failed.' , { module : 'auth-handler' , error : error . message } ) ;
206205 cliux . print ( 'CLI_AUTH_TOKEN_VALIDATION_FAILED' , { color : 'yellow' } ) ;
207- reject ( error ) ;
206+ handleAndLogError ( error , { module : 'auth-handler' } ) ;
208207 } ) ;
209208 } else {
210209 log . debug ( 'Token validation failed: no auth token provided.' , { module : 'auth-handler' } ) ;
0 commit comments