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 9407026..ca3b042 100644 --- a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java +++ b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java @@ -29,7 +29,7 @@ public class RegisterWindowController { /** * signs the user up. - * @param event the click of the signup button + * @param event the click of the sign up button */ @FXML public void handleSignUpButton(ActionEvent event) { @@ -59,6 +59,7 @@ public class RegisterWindowController { return; } + //register the user with the provided username and password userService.registerUser(userNameText.getText(), passwordField.getText()); //close the register window after the user has entered all the credentials diff --git a/src/Client/src/main/java/greenify/client/controller/UserController.java b/src/Client/src/main/java/greenify/client/controller/UserController.java index 8947d1f..abb387d 100644 --- a/src/Client/src/main/java/greenify/client/controller/UserController.java +++ b/src/Client/src/main/java/greenify/client/controller/UserController.java @@ -58,7 +58,7 @@ public class UserController { if (passwordField.getText().isEmpty()) { AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Log-in Error!", "Please enter a password"); - //checks if the password field id filled, + //checks if the password field is filled, // and gives an alert if it is not. return; } else { @@ -117,9 +117,11 @@ public class UserController { } /** - * The method handles register button. - * @param event User clicks to the button - * @throws Exception when the file couldn't be found + * The method handles the clicking of the register button. + * it then opens the register window where the user can register + * (handled by RegisterWindowController) + * @param event User clicks on the button + * @throws Exception when the fxml file couldn't be found */ public void handleRegisterButtonAction(ActionEvent event) throws Exception { Parent registerWindow = Application.load(this.getClass().getClassLoader() diff --git a/src/Client/src/main/java/greenify/client/rest/UserService.java b/src/Client/src/main/java/greenify/client/rest/UserService.java index 72547fb..ced0ec2 100644 --- a/src/Client/src/main/java/greenify/client/rest/UserService.java +++ b/src/Client/src/main/java/greenify/client/rest/UserService.java @@ -51,6 +51,7 @@ public class UserService { System.out.println(builder.build().encode().toUri()); //the result to be sent is a userDto + //encodes the userDTO object to a Uri so the database can work with it UserDto result = this.restTemplate.getForObject(builder.build() .encode().toUri(), UserDto.class); this.currentUser = result; diff --git a/src/Server/src/main/java/greenify/server/rest/UserController.java b/src/Server/src/main/java/greenify/server/rest/UserController.java index 4b06a5a..2922737 100644 --- a/src/Server/src/main/java/greenify/server/rest/UserController.java +++ b/src/Server/src/main/java/greenify/server/rest/UserController.java @@ -16,8 +16,12 @@ public class UserController { //registers a user in the userService @RequestMapping("/registerUser") + //requestMapping is for the communication (GET, POST, PUT requests) + //as with Web and Database Technology public UserDto registerUser(@RequestParam(value = "name") String name, @RequestParam(value = "password") String password) { + //the requestParams are the parameters that are sent with the request + //so in this case that it wants to register with the name and password return userService.registerUser(name, password); } @@ -28,10 +32,18 @@ public class UserController { return userService.loginUser(name, password); } - //adds a vegan meal to the user + + + /** + * adds a vegetarian meal to the user. + * @param id the id of the user + * @param name thr username of the user + */ @RequestMapping("/addVeganMeal") public void addVeganMeal(@RequestParam(value = "id") Long id, @RequestParam(value = "name") String name) { + //here the requestParams are the id and name, because that is needed for the + //addVeganMeal method of the userService userService.addVeganMeal(id, name); } } \ No newline at end of file