From 25a66832a5af6b3733025a48cc316f0a31441ccc Mon Sep 17 00:00:00 2001 From: Merel Steenbergen Date: Wed, 3 Apr 2019 21:44:50 +0200 Subject: [PATCH] ADD:: Alert for taken username --- build.gradle | 6 +++--- .../client/controller/DashBoardController.java | 2 +- .../client/controller/RegisterWindowController.java | 10 +++++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 2b6ed72..98f5661 100644 --- a/build.gradle +++ b/build.gradle @@ -18,9 +18,9 @@ apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'application' -application { - mainClassName = 'greenify.server.Application' -} +//application { +// mainClassName = 'greenify.server.Application' +//} repositories { mavenCentral() diff --git a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java index a9c3118..18d9798 100644 --- a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java +++ b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java @@ -422,7 +422,7 @@ public class DashBoardController { } /** - * method opend addFriend scene. + * method opens addFriend scene. * @throws IOException when file is not found */ public void openAddFriend() throws IOException { diff --git a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java index 11cb71f..b30c137 100644 --- a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java +++ b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java @@ -2,6 +2,7 @@ package greenify.client.controller; import greenify.client.Application; import greenify.client.rest.UserService; +import greenify.common.ApplicationException; import javafx.animation.Interpolator; import javafx.animation.KeyFrame; import javafx.animation.KeyValue; @@ -228,7 +229,14 @@ public class RegisterWindowController { } //register the user with the provided username and password - userService.registerUser(userNameText.getText(), passwordField.getText()); + try{ + userService.registerUser(userNameText.getText(), passwordField.getText()); + } + catch(RuntimeException ex){ + UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Password Error!", + "This username has already been taken!"); + return; + } //close the register window after the user has entered all the credentials Stage current = (Stage) owner; current.close();