Skip to content

Commit 5ace981

Browse files
committed
updated authentication dialog
1 parent 83ecf2b commit 5ace981

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/main/java/com/esri/samples/map/create_and_save_map/AuthenticationDialog.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import javafx.fxml.FXML;
2020
import javafx.fxml.FXMLLoader;
21+
import javafx.scene.control.Alert;
2122
import javafx.scene.control.ButtonType;
2223
import javafx.scene.control.Dialog;
2324
import javafx.scene.control.TextField;
@@ -45,20 +46,32 @@ class AuthenticationDialog extends Dialog<OAuthConfiguration> {
4546
loader.setRoot(this);
4647
loader.setController(this);
4748

49+
setTitle("Authenticate");
50+
4851
try {
4952
loader.load();
5053
} catch (Exception e) {
5154
e.printStackTrace();
5255
}
5356

5457
setResultConverter(dialogButton -> {
55-
try {
56-
return dialogButton == continueButton ? new OAuthConfiguration(portalURL.getText(), clientID.getText(),
57-
redirectURI.getText()) : null;
58-
} catch (Exception e) {
59-
return null;
58+
if (dialogButton == continueButton) {
59+
if (!portalURL.getText().equals("") && !clientID.getText().equals("") && !redirectURI.getText().equals("")) {
60+
try {
61+
return new OAuthConfiguration(portalURL.getText(), clientID.getText(), redirectURI.getText());
62+
} catch (Exception e) {
63+
Alert alert = new Alert(Alert.AlertType.ERROR);
64+
alert.setContentText(e.getMessage());
65+
alert.show();
66+
}
67+
} else {
68+
Alert alert = new Alert(Alert.AlertType.ERROR);
69+
alert.setContentText("missing credentials");
70+
alert.show();
71+
}
6072
}
73+
return null;
6174
});
6275
}
6376

64-
}
77+
}

0 commit comments

Comments
 (0)