|
@ -44,6 +44,8 @@ public class LoginGUI extends JFrame implements ActionListener { |
|
|
|
|
|
|
|
|
getRootPane().setDefaultButton(loginButton); |
|
|
getRootPane().setDefaultButton(loginButton); |
|
|
|
|
|
|
|
|
|
|
|
passwordField.addKeyListener(new EnterKeyListener()); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -56,6 +58,7 @@ public class LoginGUI extends JFrame implements ActionListener { |
|
|
private void login() { |
|
|
private void login() { |
|
|
String username = usernameField.getText(); |
|
|
String username = usernameField.getText(); |
|
|
String password = new String(passwordField.getPassword()); |
|
|
String password = new String(passwordField.getPassword()); |
|
|
|
|
|
boolean stayLoggedIn = stayLoggedInCheckbox.isSelected(); // Get checkbox state |
|
|
|
|
|
|
|
|
if (authenticateUser(username, password)) { |
|
|
if (authenticateUser(username, password)) { |
|
|
JOptionPane.showMessageDialog(this, "Login successful!"); |
|
|
JOptionPane.showMessageDialog(this, "Login successful!"); |
|
@ -67,6 +70,11 @@ public class LoginGUI extends JFrame implements ActionListener { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void updateStayLoggedIn(String username, boolean stayLoggedIn) { |
|
|
|
|
|
// Update stayLoggedIn in the JSON file for the user |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 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 |
|
|
private boolean authenticateUser(String username, String password) { |
|
|
private boolean authenticateUser(String username, String password) { |
|
|
List<CreateUser> userList = CreateUser.readUserListFromJsonFile("user.json"); |
|
|
List<CreateUser> userList = CreateUser.readUserListFromJsonFile("user.json"); |
|
|