Browse Source

Added a method to LoginGUI that calls the updateStayLoggdIn method in CreateUser if the stay logged in checkbox is ticked

remotes/origin/server
Richard Schmidt 11 months ago
parent
commit
fe008a9ebe
  1. 13
      src/main/java/LoginGUI.java
  2. 11
      user.json

13
src/main/java/LoginGUI.java

@ -46,6 +46,15 @@ public class LoginGUI extends JFrame implements ActionListener {
passwordField.addKeyListener(new EnterKeyListener()); 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 @Override
@ -71,8 +80,8 @@ public class LoginGUI extends JFrame implements ActionListener {
} }
private void updateStayLoggedIn(String username, boolean stayLoggedIn) { 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 // Function to authenticate the user by comparing the entered username and password with the saved user data

11
user.json

@ -16,15 +16,8 @@
{ {
"id": "685bc3a6-e706-4214-a5e1-8443d1a5258e", "id": "685bc3a6-e706-4214-a5e1-8443d1a5258e",
"userName": "Test User", "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", "birthday": "01.01.2000",
"stayLoggedIn": false
"stayLoggedIn": true
} }
] ]
Loading…
Cancel
Save