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
22 changes: 17 additions & 5 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,11 +180,22 @@ 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);
return;
LoginStatus loginStatus = null;
try {
loginStatus = client.login(user, password);
} catch (UnauthorizedException ex) {
if (ex.getResponse() instanceof LoginStatus status && status.isSuccess()) {
loginStatus = status;
}
}
finally {
if (loginStatus == null) {
error("Could not login to server");
System.exit(70);
}
else if (!loginStatus.isSuccess()) {
error("Could not login to server. Please check your username and password and try again.", null); System.exit(77);
}
}

String serverVersion = client.getVersion();
Expand Down
Loading