diff --git a/src/main/java/team/elrant/bubbles/gui/LoginController.java b/src/main/java/team/elrant/bubbles/gui/LoginController.java
index 3a3cae7..35c575f 100644
--- a/src/main/java/team/elrant/bubbles/gui/LoginController.java
+++ b/src/main/java/team/elrant/bubbles/gui/LoginController.java
@@ -1,10 +1,7 @@
package team.elrant.bubbles.gui;
import javafx.fxml.FXML;
-import javafx.scene.control.Button;
-import javafx.scene.control.Label;
-import javafx.scene.control.PasswordField;
-import javafx.scene.control.TextField;
+import javafx.scene.control.*;
import javafx.stage.Stage;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -29,6 +26,8 @@ public class LoginController {
private Label failedLoginLabel;
@FXML
private Label successfulLoginLabel;
+ @FXML
+ private CheckBox rememberPassword;
private @Nullable ConnectedUser connectedUser;
@@ -41,7 +40,7 @@ protected void onSubmitButtonClick() {
try {
connectedUser = new ConnectedUser(username_field.getText(), password_field.getText(), "bubbles.elrant.team");
connectedUser.initializeConnection();
- connectedUser.saveUserToFile("user.dat");
+ connectedUser.saveUserToFile("user.dat", rememberPassword.isSelected());
} catch (Exception e) {
logger.error("Error during login: {}", e.getMessage());
failedLoginLabel.setVisible(true);
diff --git a/src/main/java/team/elrant/bubbles/xmpp/ConnectedUser.java b/src/main/java/team/elrant/bubbles/xmpp/ConnectedUser.java
index b5f2d14..b5407c8 100644
--- a/src/main/java/team/elrant/bubbles/xmpp/ConnectedUser.java
+++ b/src/main/java/team/elrant/bubbles/xmpp/ConnectedUser.java
@@ -147,12 +147,16 @@ public void acceptSubscription(@NotNull BareJid contactJid, @Nullable String nic
*
* @param filename The name of the file to save the user information to.
*/
- public void saveUserToFile(@NotNull String filename) {
+ public void saveUserToFile(@NotNull String filename, boolean savePassword) {
try (@NotNull FileOutputStream fileOut = new FileOutputStream(filename);
@NotNull ObjectOutputStream objectOut = new ObjectOutputStream(fileOut)) {
- @NotNull User userWithoutPassword = new User(super.getUsername(), super.getServiceName());
- objectOut.writeObject(userWithoutPassword);
+ if (savePassword)
+ objectOut.writeObject(this);
+ else {
+ @NotNull User userToFile = new User(super.getUsername(), super.getServiceName());
+ objectOut.writeObject(userToFile);
+ }
logger.info("User information (excluding password) saved to {}", filename);
} catch (IOException e) {
diff --git a/src/main/java/team/elrant/bubbles/xmpp/User.java b/src/main/java/team/elrant/bubbles/xmpp/User.java
index 9ef4017..5412851 100644
--- a/src/main/java/team/elrant/bubbles/xmpp/User.java
+++ b/src/main/java/team/elrant/bubbles/xmpp/User.java
@@ -3,6 +3,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.io.FileInputStream;
import java.io.IOException;
@@ -18,6 +19,7 @@ public class User implements Serializable {
private final @NotNull String username;
private final @NotNull String serviceName;
+ private final @Nullable String password;
/**
* Constructs a User object with the specified username and service name.
@@ -25,9 +27,11 @@ public class User implements Serializable {
* @param username The username of the user.
* @param serviceName The service name of the XMPP server.
*/
- public User(@NotNull String username, @NotNull String serviceName) {
+
+ public User(@NotNull String username, @NotNull String serviceName, @NotNull String password) {
this.username = username;
this.serviceName = serviceName;
+ this.password = password;
}
/**
@@ -37,7 +41,8 @@ public User(@NotNull String username, @NotNull String serviceName) {
* @throws IOException If an I/O error occurs while reading the file.
* @throws ClassNotFoundException If the class of a serialized object cannot be found.
*/
- public User(@NotNull String filename) throws IOException, ClassNotFoundException {
+ public User(@NotNull String filename, @NotNull String password) throws IOException, ClassNotFoundException {
+ this.password = password;
try (FileInputStream fileIn = new FileInputStream(filename);
ObjectInputStream objectIn = new ObjectInputStream(fileIn)) {
User serializedUser = (User) objectIn.readObject();
diff --git a/src/main/resources/team/elrant/bubbles/gui/SideView.fxml b/src/main/resources/team/elrant/bubbles/gui/SideView.fxml
deleted file mode 100644
index f7e2bf2..0000000
--- a/src/main/resources/team/elrant/bubbles/gui/SideView.fxml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/main/resources/team/elrant/bubbles/gui/views/LoginView.fxml b/src/main/resources/team/elrant/bubbles/gui/views/LoginView.fxml
index 071a6fc..5433558 100644
--- a/src/main/resources/team/elrant/bubbles/gui/views/LoginView.fxml
+++ b/src/main/resources/team/elrant/bubbles/gui/views/LoginView.fxml
@@ -1,67 +1,64 @@
-
+
-
-
+
-
+
+
-
+
-
+
-
+
-
+
+
+
+
+
+
-
-
+
-
+
-
+
-
+
-
+
diff --git a/src/main/resources/team/elrant/bubbles/gui/views/SideView.fxml b/src/main/resources/team/elrant/bubbles/gui/views/SideView.fxml
index ec12bd4..c059199 100644
--- a/src/main/resources/team/elrant/bubbles/gui/views/SideView.fxml
+++ b/src/main/resources/team/elrant/bubbles/gui/views/SideView.fxml
@@ -1,8 +1,29 @@
+
+
-
-
+
+
+
+
+
+
+
+
+
+