I’ve been trying to get my logging in on my server to work for hours now!
I’ve been trying to find what was wrong with my code. I got registering an account working, and i figured that wasn’t the problem, so I tried to log into that account and even if I’m dead sure I’m right it says I failed.
After debugging this some more I narrowed it down to how I changed the log state in my account ArrayList controller thingy. Here’s the code:
public boolean login(String username, String password) {
for(int i = 0; i < accounts.size(); i++) {
TempAccount = accounts.get(i);
if(TempAccount.getUsername() == username) {
if(TempAccount.getPassword() == password) {
TempAccount.setLogged(true);
return true;
}
}
}
return false;
}
The TempAccount is just well a Temporary variable and the accounts variable is an ArrayList with only Accounts in it. Each account has a username and a password here. And I’m looping through each account checking to see if any of the credentials match. I think the loop is broken but I don’t know. What did I do wrong? Do you need more source code because I got a good 3000 lines for ya.