Hi, I am currently working on a login function for my apps. When testing it with the correct Username and password, the server responds with status ok and it goes to the content page as intended. Then, testing it with the incorrect Username or password, as intended that the server responds with “authentication failure” but it still goes to the content page (unexpected) instead of going back to the login menu.
Can you help me point out what mistakes I’ve done that causes the error?
Here is my code (C#) :
IEnumerator Login()
{
WWWForm form= new WWWForm ();
form.AddField ("name", usernamehere);
form.AddField ("pswd", passwordhere);
WWW download = new WWW (url, form);
yield return download;
if (download.error == null) {
Debug.Log (download.text);
goToContents();
}
else {
Debug.Log (download.text);
goBackToLoginMenu ();
}
}
void goBackToLoginMenu()
{
Application.LoadLevel ("LoginMenu");
}
void goToContents()
{
Application.LoadLevel ("Contents");
}