mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2026-08-21 21:32:58 +00:00
Properly handle 404 NOT FOUND at account creation
This commit is contained in:
@@ -31,6 +31,7 @@ import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@@ -231,6 +232,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||
public class UserLoginTask extends AsyncTask<Void, Void, Boolean> {
|
||||
|
||||
UserLoginTask(String serverURI, String login, String password) {
|
||||
Log.d(TAG, "_serverURI = " + serverURI);
|
||||
_serverURI = Uri.parse(serverURI);
|
||||
_login = login;
|
||||
_password = password;
|
||||
@@ -315,6 +317,10 @@ public class LoginActivity extends AppCompatActivity {
|
||||
_serverView.setError(getString(R.string.error_connection_failed));
|
||||
_serverView.requestFocus();
|
||||
break;
|
||||
case CONN_FAILED_NOT_FOUND:
|
||||
_serverView.setError(getString(R.string.error_connection_failed_not_found));
|
||||
_serverView.requestFocus();
|
||||
break;
|
||||
case INVALID_LOGIN:
|
||||
_passwordView.setError(getString(R.string.error_invalid_login));
|
||||
_passwordView.requestFocus();
|
||||
@@ -346,5 +352,6 @@ public class LoginActivity extends AppCompatActivity {
|
||||
private LoginReturnCode _returnCode;
|
||||
|
||||
public static final String PARAM_AUTHTOKEN_TYPE = "auth.token";
|
||||
private final String TAG = UserLoginTask.class.getCanonicalName();
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -136,7 +136,7 @@ public class OwnCloudAuthenticator extends AbstractAccountAuthenticator {
|
||||
}
|
||||
|
||||
try {
|
||||
if(isSuccess(status)) {
|
||||
if(OwnCloudAuthenticator.isSuccess(status)) {
|
||||
String response = get.getResponseBodyAsString();
|
||||
Log.d(OwnCloudAuthenticator.TAG, "Successful response: " + response);
|
||||
|
||||
@@ -159,7 +159,11 @@ public class OwnCloudAuthenticator extends AbstractAccountAuthenticator {
|
||||
Log.e(OwnCloudAuthenticator.TAG, "*** status code: " + status);
|
||||
}
|
||||
|
||||
bRet = (status == 401) ? LoginReturnCode.INVALID_LOGIN : LoginReturnCode.UNKNOWN_ERROR;
|
||||
switch (status) {
|
||||
case 401: bRet = LoginReturnCode.INVALID_LOGIN; break;
|
||||
case 404: bRet = LoginReturnCode.CONN_FAILED_NOT_FOUND; break;
|
||||
default: bRet = LoginReturnCode.UNKNOWN_ERROR; break;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -172,7 +176,7 @@ public class OwnCloudAuthenticator extends AbstractAccountAuthenticator {
|
||||
return bRet;
|
||||
}
|
||||
|
||||
private boolean isSuccess(int status) {
|
||||
private static boolean isSuccess(int status) {
|
||||
return (status == HttpStatus.SC_OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ public enum LoginReturnCode {
|
||||
INVALID_ADDR,
|
||||
HTTP_CONN_FAILED,
|
||||
CONN_FAILED,
|
||||
CONN_FAILED_NOT_FOUND,
|
||||
INVALID_LOGIN,
|
||||
UNKNOWN_ERROR,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user