Skip to content

56 user implemention and token. #77

Merged
merged 52 commits into from
Apr 21, 2026
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
484bcd3
Feat: BaseController is sett
Apr 15, 2026
ddc77eb
Feat: Attempt at Navbar component with dedicated fxml
Apr 15, 2026
9df6f3a
Feat: Attempt at footer components with fxml
Apr 15, 2026
89e3382
Feat: Frontpage sliced and decied
Apr 15, 2026
ed545b8
Feat: Footer controller and fxml components fully implemented?
Apr 16, 2026
fa3666a
Feat: Updated LoaderScene method to pass authToken
Apr 16, 2026
213b4b5
Feat: Updated LoaderScene method to pass authToken
Apr 16, 2026
88f32a7
Feat: Attempt to implement components to avaiableorganiszaiton
Apr 16, 2026
4b1cb07
Feat: Attempt to implement components to other pages
Apr 16, 2026
d4198df
Feat: Componetens buttons work now
Apr 16, 2026
5c6db88
Reverse commit-ish: Design fault, used email and not a username as lo…
Apr 16, 2026
04717eb
Reverse commit-ish: Design fault, used email and not a username as lo…
Apr 16, 2026
9381392
Feat: BaseController is finished, comments include instructions for m…
Apr 16, 2026
94ca5ac
Reverse commit: Refer to the commit about the revesere commit
Apr 16, 2026
1c798f9
Reverse commit: Refer to the commit about the revesere commit
Apr 16, 2026
af55452
Fix: Now makes a authToken to be passed around controllers
Apr 16, 2026
adbed95
Fix: Coloumn mismatch
Apr 16, 2026
33505ee
Feat: System can now make a user (+ Fxml for login and register and c…
Apr 16, 2026
9c82906
Commit reversal teqniceue: QWERTYUI
Apr 16, 2026
d30a4fe
Fix: hashing isn't one way. Get matching email row first, then check …
Apr 16, 2026
950ecdb
Feat: BaseController gets the HelperMethod showAleart. Now everyone c…
Apr 16, 2026
0f95e96
Feat: Login works now.
Apr 16, 2026
83f5135
Feat: Added new table for favourites
Apr 16, 2026
54303fc
Feat: Added new table for favourites + new method to get favourites
Apr 16, 2026
40d2815
Feat: Login Button changed into Profile when logged inn
Apr 18, 2026
5162b5d
Feat: Extended to LoaderScene with a another method (that points to t…
Apr 18, 2026
f1b0c56
Feat: Settings update and update user methods added
Apr 18, 2026
b5993b9
Feat: Expanded and implemented profile user.
Apr 19, 2026
4d11e3c
Feat: Attempt at favouriteDAO
Apr 19, 2026
89c5f9e
Deleted unneeded file
Apr 20, 2026
9e37945
Fix: Userfixes; Syntaxses and other stuff. Also moved into favouriites
Apr 20, 2026
3e298b9
Feat: One singular name field.
Apr 20, 2026
530a61d
Feat: Updating user settings work now
Apr 20, 2026
61862b7
Feat: Donation work. Syntax fixes and sturcutalr fixes. Favourite But…
Apr 20, 2026
ee8ba2e
Feat: Interests/Favourities and favouriting works. Basically login, g…
Apr 20, 2026
dc0737a
Fix: Major design change message contain the charity, instead of char…
Apr 20, 2026
23f53a9
Feat: Inbox works and some minor fixes to stuff
Apr 20, 2026
ec8c933
Feat: aboutPage works
Apr 21, 2026
fad1306
Feat: Expanded DonationSelect to do things
Apr 21, 2026
ea265eb
Feat: Viewing donations work yey
Apr 21, 2026
6cf34de
Feat: Implementing charityUser, new methods for showing its a charity…
Apr 21, 2026
efd31df
Feat: Updating (org_settings) work
Apr 21, 2026
e64128b
Feat: Updating descirptng (org_Edit) works.
Apr 21, 2026
020742f
Feat: FrontPage donate button works
Apr 21, 2026
a5fdf85
Feat: Getting donations from doners ad charityUser working
Apr 21, 2026
35f72aa
Feat: We'll see if feedback work/messages work
Apr 21, 2026
4cd19f3
Feat: Messages work
Apr 21, 2026
9a608e2
Fix: Duplicate entry fix, unqiue donation id everytime + small fixes
Apr 21, 2026
75d3138
All should be as it was designed
Apr 21, 2026
2826454
Shitty as fxml (grr i hate fxml) turns every text white for some reas…
Apr 21, 2026
6b4e76f
Fix: attempt to fix avaliable organizaitons but it does nothing athe …
Apr 21, 2026
4da7e5d
Merge branch 'develop' of git.ntnu.no:cathrkri/systemutviklingTeam6 i…
Apr 21, 2026
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
Binary file modified docs/SqlDatabase/ER-DiagramFile.mwb
Binary file not shown.
Binary file modified docs/SqlDatabase/ER-DiagramFile.mwb.bak
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,35 @@
import java.util.Objects;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import ntnu.systemutvikling.team6.controller.components.BaseController;
import ntnu.systemutvikling.team6.database.DAO.UserDAO;
import ntnu.systemutvikling.team6.database.DatabaseConnection;
import ntnu.systemutvikling.team6.database.DatabaseSetup;
import ntnu.systemutvikling.team6.database.Readers.UserSelect;
import ntnu.systemutvikling.team6.models.Charity;
import ntnu.systemutvikling.team6.models.registry.CharityRegistry;
import ntnu.systemutvikling.team6.scraper.FullCharityScrape;
import ntnu.systemutvikling.team6.service.APIToDatabaseService;
import ntnu.systemutvikling.team6.service.AuthenticationService;

public class HmHApplication extends Application {
@Override
public void start(Stage stage) throws Exception {
DatabaseConnection conn = new DatabaseConnection();
AuthenticationService authToken = new AuthenticationService(new UserSelect(conn), new UserDAO(conn));

FXMLLoader fxmlLoader =
new FXMLLoader(HmHApplication.class.getResource("/fxml/frontPage.fxml"));
Scene scene = new Scene(fxmlLoader.load());


BaseController controller = fxmlLoader.getController();
controller.setAuthToken(authToken);

Image icon =
new Image(
Objects.requireNonNull(HmHApplication.class.getResource("/images/Logo.png"))
Expand Down Expand Up @@ -72,6 +86,8 @@ public void init() {
e.printStackTrace();
}
System.out.println("-- \n Init complete \n --");


}

public static void main(String[] args) {
Expand Down
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
import javafx.scene.Parent;
import javafx.scene.control.TextField;
import javafx.scene.layout.FlowPane;
import ntnu.systemutvikling.team6.controller.components.BaseController;
import ntnu.systemutvikling.team6.controller.components.LoaderScene;
import ntnu.systemutvikling.team6.controller.components.NavbarFooterController;
import ntnu.systemutvikling.team6.controller.components.OrganizationCardController;
import ntnu.systemutvikling.team6.controller.components.*;
import ntnu.systemutvikling.team6.database.DatabaseConnection;
import ntnu.systemutvikling.team6.database.Readers.CharitySelect;
import ntnu.systemutvikling.team6.models.Charity;
Expand All @@ -26,15 +23,22 @@
* on the featured charity to see more details about it. The user can also switch to the charity
* page or donation page for the selected charity.
*/
public class AvailableOrganizationController extends BaseController
implements NavbarFooterController {
public class AvailableOrganizationController extends BaseController {

@FXML private TextField searchField;
@FXML private FlowPane cardsContainer;
@FXML private NavbarController navbarController;
@FXML private FooterController footerController;

private Charity charity;
private List<Charity> allCharities;

@Override
protected void authTokenisSet(){
navbarController.setAuthToken(authToken);
footerController.setAuthToken(authToken);
}

/**
* This method is used to initialize the available organization page. It retrieves all charities
* from the database and sets up a listener on the search field to filter the charities based on
Expand Down Expand Up @@ -93,8 +97,7 @@ private void displayCharities(List<Charity> charities) {

for (Charity charity : charities) {
try {
FXMLLoader loader =
new FXMLLoader(getClass().getResource("/fxml/components/organizationCard.fxml"));
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/components/organizationCard.fxml"));
Parent card = loader.load();

OrganizationCardController cardController = loader.getController();
Expand All @@ -121,13 +124,14 @@ public void setInitialSearch(String query) {
searchField.setText(query);
}


/**
* This method is used to switch to the charity page for the selected charity.
*
* @param event action event from button click
*/
public void switchToCharityPage(ActionEvent event) {
LoaderScene.LoadScene("CharityPage", event, charity, null);
LoaderScene.LoadScene("CharityPage", event, charity, null, authToken);
}

/**
Expand All @@ -137,6 +141,6 @@ public void switchToCharityPage(ActionEvent event) {
*/
@FXML
public void switchToDonationPage(ActionEvent event) {
LoaderScene.LoadScene("DonationPage", event, charity, null);
LoaderScene.LoadScene("DonationPage", event, charity, null, authToken);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package ntnu.systemutvikling.team6.controller;

import javafx.event.ActionEvent;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
Expand All @@ -15,14 +15,17 @@
import javafx.scene.layout.VBox;
import javafx.scene.shape.Arc;
import javafx.scene.shape.Rectangle;
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;
import ntnu.systemutvikling.team6.models.Charity;

/**
* This controller represents the charity page, where the user can read about the charity and choose
* to donate to it. It also has a button to return to the front page.
*/
public class CharityPageController {
public class CharityPageController extends BaseController {
@FXML private TextField charitySearchField;

@FXML private Label CharityDescription;
Expand All @@ -47,9 +50,19 @@ public class CharityPageController {

@FXML private VBox categoriesContainer;

@FXML private NavbarController navbarController;
@FXML private FooterController footerController;

@FXML
public void initialize() {}

@Override
protected void authTokenisSet(){
navbarController.setAuthToken(authToken);
footerController.setAuthToken(authToken);
}


private Charity charity;

/**
Expand All @@ -69,6 +82,7 @@ public void setCharity(Charity charity) {
CharityDescription.setText(charity.getDescription());
CharityName.setText(charity.getName());


if (this.charity.getLogoBlob() != null) {
ByteArrayInputStream logoByteStream = new ByteArrayInputStream(this.charity.getLogoBlob());
Image CharityLogoImage = new Image(logoByteStream);
Expand Down Expand Up @@ -112,13 +126,13 @@ public void setCharity(Charity charity) {
@FXML
public void switchToDonationPage(ActionEvent event) {
System.out.println("Click");
LoaderScene.LoadScene("donationPage", event, charity, null);
LoaderScene.LoadScene("donationPage", event, charity, null, authToken);
}

@FXML
public void switchToFrontPage(ActionEvent event) {
System.out.println("Click");
LoaderScene.LoadScene("FrontPage", event, charity, null);
LoaderScene.LoadScene("FrontPage", event, charity, null, authToken);
}

/**
Expand All @@ -127,14 +141,9 @@ public void switchToFrontPage(ActionEvent event) {
* @param event is the event that triggered the search.
*/
@FXML
public void handleSearch(ActionEvent event) {
String query = charitySearchField.getText().trim();

if (query.isEmpty()) {
return;
}
private void switchToFeedbackPage(ActionEvent event){
LoaderScene.LoadScene("giveFeedback", event, charity, null, authToken);

LoaderScene.LoadScene("availableOrganization", event, null, query);
}

/**
Expand Down
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);
}
}
Loading
Loading