Skip to content

Commit

Permalink
burn last remaining email stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
alyssaruth committed Sep 3, 2024
1 parent 036f889 commit 63bacf4
Show file tree
Hide file tree
Showing 12 changed files with 3 additions and 427 deletions.
66 changes: 2 additions & 64 deletions client/src/main/java/online/screen/AccountSettingsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public AccountSettingsDialog(String username, String email)
okCancelPanel.add(btnChangePassword);
okCancelPanel.add(btnCancel);
textFieldUsername.setEditable(false);
textFieldEmail.setEditable(false);

btnChangePassword.addActionListener(this);
btnOk.addActionListener(this);
Expand All @@ -78,54 +79,6 @@ private void init()
textFieldEmail.setText(email);
}

private boolean valid()
{
String newEmail = textFieldEmail.getText();
if (email.equals(newEmail))
{
return true;
}

if (newEmail == null || newEmail.isEmpty())
{
String question = "Are you sure you want to unset your email address?";
question += "\n\nIf you forget your password you will not be able to regain access to your account.";
int option = DialogUtil.showQuestion(question, false);
return option == JOptionPane.YES_OPTION;
}

return AccountUtil.validateEmail(newEmail);
}

private void saveNewAccountDetails()
{
String newEmail = textFieldEmail.getText();
if (email.equals(newEmail))
{
dispose();
return;
}

boolean sendTestEmail = false;
if (!newEmail.isEmpty())
{
String question = "Would you like to send a test email to your new account?";
int option = DialogUtil.showQuestion(question, false);
sendTestEmail = option == JOptionPane.YES_OPTION;
}

Document message = XmlBuilderClient.factoryChangeEmailRequest(username, email, newEmail, sendTestEmail);
MessageUtil.sendMessage(message, 0);
}

public void emailChangedSuccessfully()
{
EntropyLobby lobby = ScreenCache.getEntropyLobby();
lobby.setEmail(textFieldEmail.getText());
DialogUtil.showInfoLater("Account settings changed successfully.");
disposeLater();
}

@Override
public void actionPerformed(ActionEvent arg0)
{
Expand All @@ -140,10 +93,7 @@ public void actionPerformed(ActionEvent arg0)
}
else if (source == btnOk)
{
if (valid())
{
saveNewAccountDetails();
}
dispose();
}
else if (source == btnCancel)
{
Expand All @@ -154,16 +104,4 @@ else if (source == btnCancel)
Debug.stackTrace("Unexpected actionPerformed: " + source);
}
}

private void disposeLater()
{
SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
{
dispose();
}
});
}
}
64 changes: 1 addition & 63 deletions client/src/main/java/online/screen/LoginDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,8 @@ public LoginDialog()
getContentPane().add(lblCreateAccount);
lblCreateAccount.setForeground(Color.BLUE);
lblCreateAccount.setFont(new Font("Tahoma", Font.BOLD, 12));
lblForgottenPassword.setHorizontalAlignment(SwingConstants.CENTER);
lblForgottenPassword.setForeground(Color.BLUE);
lblForgottenPassword.setFont(new Font("Tahoma", Font.BOLD, 12));
lblForgottenPassword.setBounds(51, 111, 150, 20);
getContentPane().add(lblForgottenPassword);

lblCreateAccount.addMouseListener(this);
lblForgottenPassword.addMouseListener(this);
btnLogin.addActionListener(this);
btnCancel.addActionListener(this);
}
Expand All @@ -82,7 +76,6 @@ public LoginDialog()
private final JLabel lblPassword = new JLabel("Password");
private final JPasswordField passwordField = new JPasswordField();
private final JLabel lblCreateAccount = new JLabel("<html><u>Create Account</u></html>");
private final JLabel lblForgottenPassword = new JLabel("<html><u>Forgotten Password</u></html>");
private final JButton btnLogin = new JButton("Log In");
private final JButton btnCancel = new JButton("Cancel");

Expand Down Expand Up @@ -140,46 +133,7 @@ private void sendLoginMessage()
DialogUtil.showErrorLater("Unable to initiate request.");
}
}

private void resetPassword()
{
String username = "";
while (username == null || username.isEmpty())
{
if (username == null)
{
return;
}

username = JOptionPane.showInputDialog(this, "Please enter your username", "Reset Password", JOptionPane.PLAIN_MESSAGE);
}

String email = "";
while (email == null || email.isEmpty())
{
if (email == null)
{
return;
}

email = JOptionPane.showInputDialog(this, "Please enter the email for this account", "Reset Password", JOptionPane.PLAIN_MESSAGE);
}

boolean success = XmlBuilderClient.sendSymmetricKeyRequest();
if (success)
{
ScreenCache.showConnectingDialog();
Document resetPasswordRequest = XmlBuilderClient.factoryResetPasswordRequest(username, email);
MessageUtil.sendMessage(resetPasswordRequest, 0, 0);
}
else
{
DialogUtil.showErrorLater("Unable to initiate request.");
}
}




/**
* MouseListener
*/
Expand All @@ -198,10 +152,6 @@ public void mouseClicked(MouseEvent arg0)
dialog.setResizable(false);
dialog.setVisible(true);
}
else if (source == lblForgottenPassword)
{
resetPassword();
}
}
@Override
public void mouseEntered(MouseEvent arg0)
Expand Down Expand Up @@ -241,16 +191,4 @@ else if (source == btnCancel)
Debug.stackTrace("Unexpected source for ActionListener: " + source);
}
}

public void disposeLater()
{
SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
{
dispose();
}
});
}
}
41 changes: 0 additions & 41 deletions client/src/main/java/online/util/ResponseHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@ else if (responseName.equals(RESPONSE_TAG_CHANGE_PASSWORD))
{
handleChangePasswordResponse(root);
}
else if (responseName.equals(RESPONSE_TAG_CHANGE_EMAIL))
{
handleChangeEmailResponse(root);
}
else if (responseName.equals(RESPONSE_TAG_RESET_PASSWORD))
{
handleResetPasswordResponse(root);
}
else if (responseName.equals(RESPONSE_TAG_CONNECT_SUCCESS))
{
handleConnectSuccess(root, lobby);
Expand Down Expand Up @@ -177,39 +169,6 @@ private static void handleChangePasswordResponse(Element root)
}
}

private static void handleChangeEmailResponse(Element root)
{
AccountSettingsDialog changeEmailDialog = ScreenCache.getAccountSettingsDialog();

String error = root.getAttribute("Error");
if (!error.isEmpty())
{
DialogUtil.showErrorLater(error);
}
else
{
changeEmailDialog.emailChangedSuccessfully();
}
}

private static void handleResetPasswordResponse(Element root)
{
ScreenCache.dismissConnectingDialog();

String failureReason = root.getAttribute("FailureReason");
if (!failureReason.isEmpty())
{
DialogUtil.showErrorLater(failureReason);
}
else
{
String successMessage = "Password reset successfully."
+ "\n\nYour new password has been sent to the email address provided.";

DialogUtil.showInfoLater(successMessage);
}
}

private static void handleConnectSuccess(Element root, final EntropyLobby lobby)
{
ScreenCache.dismissConnectingDialog();
Expand Down
24 changes: 0 additions & 24 deletions client/src/main/java/online/util/XmlBuilderClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,6 @@ public static Document factoryChangePasswordRequest(String username, String oldP
return document;
}

public static Document factoryChangeEmailRequest(String username, String oldEmail, String newEmail, boolean sendTest)
{
Document document = XmlUtil.factoryNewDocument();
Element rootElement = document.createElement(ROOT_TAG_CHANGE_EMAIL_REQUEST);
rootElement.setAttribute("Username", username);
rootElement.setAttribute("EmailOld", oldEmail);
rootElement.setAttribute("EmailNew", newEmail);
XmlUtil.setAttributeBoolean(rootElement, "SendTest", sendTest);

document.appendChild(rootElement);
return document;
}

public static Document factoryConnectionRequest(String username, String passwordHash, boolean mobile)
{
Document document = XmlUtil.factoryNewDocument();
Expand All @@ -156,17 +143,6 @@ public static Document factoryConnectionRequest(String username, String password
return document;
}

public static Document factoryResetPasswordRequest(String username, String email)
{
Document document = XmlUtil.factoryNewDocument();
Element rootElement = document.createElement(ROOT_TAG_RESET_PASSWORD_REQUEST);
rootElement.setAttribute("Username", username);
rootElement.setAttribute("Email", email);

document.appendChild(rootElement);
return document;
}

public static Document factoryDisconnectRequest(String username)
{
Document document = XmlUtil.factoryNewDocument();
Expand Down
1 change: 0 additions & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ plugins {
ktfmt { kotlinLangStyle() }

dependencies {
implementation("javax.mail:javax.mail-api:1.6.2")
implementation("javax.activation:activation:1.1.1")
testImplementation(project(":test-core"))
}
90 changes: 0 additions & 90 deletions core/src/main/java/util/EmailUtil.java

This file was deleted.

Loading

0 comments on commit 63bacf4

Please sign in to comment.