Improved logging in

This commit is contained in:
JKetelaar
2015-05-03 22:40:24 +02:00
parent c3f3aa21b9
commit 0be2a6e00c
3 changed files with 18 additions and 4 deletions
@@ -82,6 +82,9 @@ public final class AccountManager {
String api = (String) ((JSONObject) result.get("data")).get("api");
account = new Account(user, pass, api);
return true;
}else if (result.get("error") != null){
Core.verbose((String) result.get("error"));
return false;
}
}
return false;
+11 -4
View File
@@ -5,6 +5,7 @@ import org.parabot.core.Core;
import org.parabot.core.forum.AccountManager;
import org.parabot.core.ui.images.Images;
import org.parabot.core.ui.utils.SwingUtil;
import org.parabot.core.ui.utils.UILog;
import javax.swing.*;
import java.awt.*;
@@ -38,7 +39,15 @@ public class LoginUI extends JFrame {
String password = new String(txtPassword.getPassword());
if (username.length() > 0 && password.length() > 0) {
attempt(username, password);
if (manager.login(username, password)) {
Core.verbose("Logged in.");
instance.dispose();
Core.verbose("Running server selector.");
ServerSelector.getInstance();
} else {
Core.verbose("Failed to log in.");
UILog.log("Error", "Incorrect username or password. Have you tried logging into http://bdn.parabot.org/account/", JOptionPane.ERROR_MESSAGE);
}
}
}
@@ -51,9 +60,7 @@ public class LoginUI extends JFrame {
ServerSelector.getInstance();
} else {
Core.verbose("Failed to log in.");
JOptionPane.showMessageDialog(null,
"Incorrect username or password. Have you tried logging into http://bdn.parabot.org/account/", "Error",
JOptionPane.ERROR_MESSAGE);
UILog.log("Error", "Incorrect username or password. Have you tried logging into http://bdn.parabot.org/account/", JOptionPane.ERROR_MESSAGE);
}
}
@@ -7,6 +7,7 @@ import org.parabot.core.forum.AccountManagerAccess;
import org.parabot.core.io.ProgressListener;
import org.parabot.core.ui.ServerSelector;
import org.parabot.core.ui.images.Images;
import org.parabot.core.ui.utils.UILog;
import javax.swing.*;
import java.awt.*;
@@ -134,6 +135,9 @@ public class VerboseLoader extends JPanel implements ProgressListener {
public void actionPerformed(ActionEvent e) {
if(manager.login(userInput.getText(), passInput.getText())) {
switchState(STATE_SERVER_SELECT);
} else {
Core.verbose("Failed to log in.");
UILog.log("Error", "Incorrect username or password. Have you tried logging into http://bdn.parabot.org/account/", JOptionPane.ERROR_MESSAGE);
}
}