-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from cathrkri/56-user-implemention-and-token
56 user implemention and token.
- Loading branch information
Showing
71 changed files
with
5,232 additions
and
6,043 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...papplication/src/main/java/ntnu/systemutvikling/team6/controller/AboutPageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package ntnu.systemutvikling.team6.controller; | ||
|
|
||
| import javafx.fxml.FXML; | ||
| import ntnu.systemutvikling.team6.controller.components.BaseController; | ||
| import ntnu.systemutvikling.team6.controller.components.FooterController; | ||
| import ntnu.systemutvikling.team6.controller.components.NavbarController; | ||
|
|
||
| public class AboutPageController extends BaseController { | ||
| @FXML private NavbarController navbarController; | ||
| @FXML private FooterController footerController; | ||
|
|
||
| @Override | ||
| protected void authTokenisSet() { | ||
| navbarController.setAuthToken(authToken); | ||
| footerController.setAuthToken(authToken); | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...ication/src/main/java/ntnu/systemutvikling/team6/controller/CreateUserPageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| package ntnu.systemutvikling.team6.controller; | ||
|
|
||
| import javafx.event.ActionEvent; | ||
| import javafx.fxml.FXML; | ||
| import javafx.scene.control.Alert; | ||
| import javafx.scene.control.PasswordField; | ||
| import javafx.scene.control.TextField; | ||
| import ntnu.systemutvikling.team6.controller.components.BaseController; | ||
| import ntnu.systemutvikling.team6.controller.components.FooterController; | ||
| import ntnu.systemutvikling.team6.controller.components.LoaderScene; | ||
| import ntnu.systemutvikling.team6.controller.components.NavbarController; | ||
|
|
||
|
|
||
|
|
||
| public class CreateUserPageController extends BaseController { | ||
| @FXML | ||
| private NavbarController navbarController; | ||
| @FXML | ||
| private FooterController footerController; | ||
|
|
||
| @FXML private TextField firstNameField; | ||
| @FXML private TextField emailField; | ||
| @FXML private PasswordField passwordField; | ||
| @FXML private PasswordField confirmPasswordField; | ||
|
|
||
|
|
||
| @Override | ||
| protected void authTokenisSet() { | ||
| if (isLoggedin()){ | ||
| LoaderScene.LoadScene("frontPage", new ActionEvent(), null, null, authToken); | ||
| } | ||
| navbarController.setAuthToken(authToken); | ||
| footerController.setAuthToken(authToken); | ||
| } | ||
|
|
||
| @FXML | ||
| private void handleCreateAccount(ActionEvent event){ | ||
| String nameText = firstNameField.getText(); | ||
| String emailText = emailField.getText(); | ||
| String password = passwordField.getText(); | ||
| String confirmPassword = confirmPasswordField.getText(); | ||
|
|
||
| if (nameText.isBlank() || emailText.isBlank() || password.isBlank() || confirmPassword.isBlank()) { | ||
| showAlert(Alert.AlertType.ERROR, "Empty input", "Please fill out all fields"); | ||
| return; | ||
| } | ||
|
|
||
| if (emailText == null || emailText.isBlank() || !emailText.contains("@") || !emailText.contains(".")) { | ||
| showAlert(Alert.AlertType.ERROR, "Invalid Email", "Please enter a valid email"); | ||
| return; | ||
| } | ||
|
|
||
| if (!password.equals(confirmPassword)) { | ||
| showAlert(Alert.AlertType.ERROR, "Mismatch of password", "Password do not match"); | ||
| return; | ||
| } | ||
|
|
||
| // login | ||
| boolean registerSuccess; | ||
| try { | ||
| registerSuccess = authToken.register(nameText,emailText, confirmPassword); | ||
| } catch (IllegalArgumentException e) { | ||
| showAlert(Alert.AlertType.ERROR, "Email already taken", "Email already taken by another user."); | ||
| return; | ||
| } catch (Exception e) { | ||
| e.printStackTrace(); | ||
| showAlert(Alert.AlertType.ERROR, "Unexpected Error", "Unexpected error ocurred"); | ||
| return; | ||
|
|
||
| } | ||
| if (registerSuccess) { | ||
| showAlert( | ||
| Alert.AlertType.INFORMATION, | ||
| "Sign up sucsess", | ||
| "You have registered a new account! Please login with same credentials"); | ||
| LoaderScene.LoadScene("loginSite", event, null, null, authToken); | ||
| } | ||
| } | ||
|
|
||
| @FXML | ||
| private void switchToLoginPage(ActionEvent event){ | ||
| System.out.println("Click!"); | ||
| LoaderScene.LoadScene("loginSite", event, null, null, authToken); | ||
| } | ||
| } |
Oops, something went wrong.