mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2025-06-19 22:06:21 +00:00
Properly handle 404 NOT FOUND at account creation
This commit is contained in:
parent
38c933477f
commit
678fe0b720
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
|
||||
|
@ -170,5 +170,6 @@
|
||||
<string name="action_appinfo_perms">App Infos and permissions</string>
|
||||
<string name="restore_all_messages">Restore all messages</string>
|
||||
<string name="account_actions">Account actions</string>
|
||||
<string name="error_connection_failed_not_found">Connection failed, the server returns 404 NOT FOUND. Ensure you set the correct path for your ownCloud instance.</string>
|
||||
|
||||
</resources>
|
||||
|
@ -155,4 +155,5 @@
|
||||
<string name="action_appinfo_perms">Infos et permissions</string>
|
||||
<string name="restore_all_messages">Restaurer tous les messages</string>
|
||||
<string name="account_actions">Actions du compte</string>
|
||||
<string name="error_connection_failed_not_found">Echec de connexion, le serveur a retourné 404 NON TROUVE. Assurez vous d\'avoir spécifié la bonne URL.</string>
|
||||
</resources>
|
||||
|
@ -205,4 +205,5 @@
|
||||
<string name="action_appinfo_perms">App Infos and permissions</string>
|
||||
<string name="restore_all_messages">Restore all messages</string>
|
||||
<string name="account_actions">Account actions</string>
|
||||
<string name="error_connection_failed_not_found">Connection failed, the server returns 404 NOT FOUND. Ensure you set the correct path for your ownCloud instance.</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user