Closed aschenoni closed 10 years ago
There were two problems - the code was still using local authentication:
for (String credential : DUMMY_CREDENTIALS) {
String[] pieces = credential.split(":");
if (pieces[0].equals(mUsername)) {
// Account exists, return true if the password matches.
return pieces[1].equals(mPassword);
}
}
And the Android emulator allows Internet access when I tried it, but the server specified in the code does not seem to exist and throws some sort of host not found exception - however, changing it to the examples you provided above works.
The current code works by constructing a GET with mUsername
and mPassword
to your webapp hosted above and checking (response.equals("1"))
- it works, but I assume we'd want to change it back to POST, so I just commented out your original authentication line.
The webserver works, but the app always seems to take it that the password is incorrect. If you guys could help me look into the issue, the loginActivity.java is a little confusing.
You can preview the three example outputs by going to these links: Username AND Password correct (1): http://buzzfunds.herokuapp.com/loginserver?username=admin&password=pass123 Username correct Password incorrect (0): http://buzzfunds.herokuapp.com/loginserver?username=admin&password=wrongpassword Username not in database (unregistered) (-1): http://buzzfunds.herokuapp.com/loginserver?username=madeUpUsername&password=pass123
The default android emulator does not seem to allow internet access. I had to use Genymotion instead, which I would recommend anyway because it is faster.