Skip to content

Commit

Permalink
Feat: BaseController is finished, comments include instructions for m…
Browse files Browse the repository at this point in the history
…aking new controller, to make sure authToken gets based correctly
  • Loading branch information
AdrianBalunan committed Apr 16, 2026
1 parent 04717eb commit 9381392
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ntnu.systemutvikling.team6.controller.components;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import ntnu.systemutvikling.team6.service.AuthenticationService;

public abstract class BaseController {
Expand All @@ -10,11 +12,27 @@ public void setAuthToken(AuthenticationService authToken){
authTokenisSet();
};
protected abstract void authTokenisSet();
// Update ui (login button or profile circle) after authtoken is set, on each controller.
// Update ui (login button or profile circle) after authtoken is set:
// Make sure to invoke navbarController.setAuthtoken AND FooterController on controller that have @FXML private navbarController as an attribute.
// If footerController and NavbarController on the same file overwrite one of the controllers switchtofrontpage.



protected boolean isLoggedin(){
return authToken.isLoggedin() && authToken != null;
return authToken != null && authToken.isLoggedin();
}

// Example on the minimum inside of a controller that extends the baseControlle and inserts footer and navbar fxml:
/*
@FXML
private NavbarController navbarController;
@FXML private FooterController footerController;
@Override
protected void authTokenisSet() {
navbarController.setAuthToken(authToken);
footerController.setAuthToken(authToken);
}
*/

}

0 comments on commit 9381392

Please sign in to comment.