diff --git a/src/main/java/LoginGUI.java b/src/main/java/LoginGUI.java index b273014..675ffa5 100644 --- a/src/main/java/LoginGUI.java +++ b/src/main/java/LoginGUI.java @@ -46,6 +46,15 @@ public class LoginGUI extends JFrame implements ActionListener { passwordField.addKeyListener(new EnterKeyListener()); + stayLoggedInCheckbox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + boolean stayLoggedIn = stayLoggedInCheckbox.isSelected(); + String username = usernameField.getText(); + updateStayLoggedIn(username, stayLoggedIn); + } + }); + } @Override @@ -71,8 +80,8 @@ public class LoginGUI extends JFrame implements ActionListener { } private void updateStayLoggedIn(String username, boolean stayLoggedIn) { - // Update stayLoggedIn in the JSON file for the user - + // Update stayLoggedIn in the JSON file for the user + CreateUser.updateStayLoggedIn("user.json", username, stayLoggedIn); } // Function to authenticate the user by comparing the entered username and password with the saved user data diff --git a/user.json b/user.json index 893012b..5437c96 100644 --- a/user.json +++ b/user.json @@ -16,15 +16,8 @@ { "id": "685bc3a6-e706-4214-a5e1-8443d1a5258e", "userName": "Test User", - "password": "TestPasswort123", - "birthday": "01.01.2000", - "stayLoggedIn": false - }, - { - "id": "503f2d6a-389c-4675-8044-3ec9ca73f1b5", - "userName": "Test User", - "password": "TestPasswort123", + "password": "Test", "birthday": "01.01.2000", - "stayLoggedIn": false + "stayLoggedIn": true } ] \ No newline at end of file