Skip to content

Commit 1089221

Browse files
committed
Don't mask non-authentication errors in iam login
1 parent 5b9ca67 commit 1089221

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

client/src/commands.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -570,19 +570,17 @@ async fn iam(
570570
Ok(())
571571
}
572572

573-
IdentityCommand::Login => {
574-
if let Err(ClientError::ErrorResponse(err)) = client.identities().send().await
575-
&& err.status() == StatusCode::UNAUTHORIZED
576-
{
573+
IdentityCommand::Login => match client.identities().send().await {
574+
Ok(_) => Ok(()),
575+
Err(ClientError::ErrorResponse(err)) if err.status() == StatusCode::UNAUTHORIZED => {
577576
let (identity, credentials) =
578577
authz(ctx, client, ssh_auth_sock, ssh_key_id, err).await?;
579578
ctx.iam(&identity)?;
580579
ctx.set_credentials(Some(credentials));
581580
Ok(())
582-
} else {
583-
Err(CommandError::InvalidAuthorization)
584581
}
585-
}
582+
Err(err) => Err(err.into()),
583+
},
586584

587585
IdentityCommand::Revoke { revoke } => {
588586
let revoke = ctx.really_revoke(revoke)?;

0 commit comments

Comments
 (0)