Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions command/src/com/mirth/connect/cli/CommandLineInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import com.mirth.connect.client.core.PaginatedEventList;
import com.mirth.connect.client.core.PaginatedMessageList;
import com.mirth.connect.client.core.PropertiesConfigurationUtil;
import com.mirth.connect.client.core.UnauthorizedException;
import com.mirth.connect.donkey.model.channel.DeployedState;
import com.mirth.connect.donkey.model.message.ContentType;
import com.mirth.connect.donkey.model.message.Message;
Expand Down Expand Up @@ -179,10 +180,21 @@ private void runShell(String server, String user, String password, String script
client = new Client(server);
this.debug = debug;

LoginStatus loginStatus = client.login(user, password);

if (loginStatus.getStatus() != LoginStatus.Status.SUCCESS) {
error("Could not login to server.", null);
LoginStatus loginStatus;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LoginStatus loginStatus;
LoginStatus loginStatus = null;

Changes below will complain that loginStatus may have not been initialized without this.

try {
loginStatus = client.login(user, password);
} catch (UnauthorizedException ex) {
if (ex.getResponse() instanceof LoginStatus status) {
loginStatus = status;
}
else {
error("Could not login to server.", ex);
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return;
System.exit(77);

77 is the unix exit code for EX_NOPERM. This code is already using exit code 2 for usage errors.

}
}

if (!loginStatus.isSuccess()) {
error("Could not login to server. Status: " + loginStatus.getStatus(), null);
return;
Comment on lines +197 to 198
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
error("Could not login to server. Status: " + loginStatus.getStatus(), null);
return;
error("Could not login to server. Please check your username and password and try again.", null);
System.exit(77);

77 is the unix exit code for EX_NOPERM. This code is already using exit code 2 for usage errors.

}

Expand Down