mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2025-06-20 14:26:15 +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.provider.Settings;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
@ -231,6 +232,7 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
public class UserLoginTask extends AsyncTask<Void, Void, Boolean> {
|
public class UserLoginTask extends AsyncTask<Void, Void, Boolean> {
|
||||||
|
|
||||||
UserLoginTask(String serverURI, String login, String password) {
|
UserLoginTask(String serverURI, String login, String password) {
|
||||||
|
Log.d(TAG, "_serverURI = " + serverURI);
|
||||||
_serverURI = Uri.parse(serverURI);
|
_serverURI = Uri.parse(serverURI);
|
||||||
_login = login;
|
_login = login;
|
||||||
_password = password;
|
_password = password;
|
||||||
@ -315,6 +317,10 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
_serverView.setError(getString(R.string.error_connection_failed));
|
_serverView.setError(getString(R.string.error_connection_failed));
|
||||||
_serverView.requestFocus();
|
_serverView.requestFocus();
|
||||||
break;
|
break;
|
||||||
|
case CONN_FAILED_NOT_FOUND:
|
||||||
|
_serverView.setError(getString(R.string.error_connection_failed_not_found));
|
||||||
|
_serverView.requestFocus();
|
||||||
|
break;
|
||||||
case INVALID_LOGIN:
|
case INVALID_LOGIN:
|
||||||
_passwordView.setError(getString(R.string.error_invalid_login));
|
_passwordView.setError(getString(R.string.error_invalid_login));
|
||||||
_passwordView.requestFocus();
|
_passwordView.requestFocus();
|
||||||
@ -346,5 +352,6 @@ public class LoginActivity extends AppCompatActivity {
|
|||||||
private LoginReturnCode _returnCode;
|
private LoginReturnCode _returnCode;
|
||||||
|
|
||||||
public static final String PARAM_AUTHTOKEN_TYPE = "auth.token";
|
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 {
|
try {
|
||||||
if(isSuccess(status)) {
|
if(OwnCloudAuthenticator.isSuccess(status)) {
|
||||||
String response = get.getResponseBodyAsString();
|
String response = get.getResponseBodyAsString();
|
||||||
Log.d(OwnCloudAuthenticator.TAG, "Successful response: " + response);
|
Log.d(OwnCloudAuthenticator.TAG, "Successful response: " + response);
|
||||||
|
|
||||||
@ -159,7 +159,11 @@ public class OwnCloudAuthenticator extends AbstractAccountAuthenticator {
|
|||||||
Log.e(OwnCloudAuthenticator.TAG, "*** status code: " + status);
|
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) {
|
} catch (Exception e) {
|
||||||
@ -172,7 +176,7 @@ public class OwnCloudAuthenticator extends AbstractAccountAuthenticator {
|
|||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSuccess(int status) {
|
private static boolean isSuccess(int status) {
|
||||||
return (status == HttpStatus.SC_OK);
|
return (status == HttpStatus.SC_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@ public enum LoginReturnCode {
|
|||||||
INVALID_ADDR,
|
INVALID_ADDR,
|
||||||
HTTP_CONN_FAILED,
|
HTTP_CONN_FAILED,
|
||||||
CONN_FAILED,
|
CONN_FAILED,
|
||||||
|
CONN_FAILED_NOT_FOUND,
|
||||||
INVALID_LOGIN,
|
INVALID_LOGIN,
|
||||||
UNKNOWN_ERROR,
|
UNKNOWN_ERROR,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,5 +170,6 @@
|
|||||||
<string name="action_appinfo_perms">App Infos and permissions</string>
|
<string name="action_appinfo_perms">App Infos and permissions</string>
|
||||||
<string name="restore_all_messages">Restore all messages</string>
|
<string name="restore_all_messages">Restore all messages</string>
|
||||||
<string name="account_actions">Account actions</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>
|
</resources>
|
||||||
|
@ -155,4 +155,5 @@
|
|||||||
<string name="action_appinfo_perms">Infos et permissions</string>
|
<string name="action_appinfo_perms">Infos et permissions</string>
|
||||||
<string name="restore_all_messages">Restaurer tous les messages</string>
|
<string name="restore_all_messages">Restaurer tous les messages</string>
|
||||||
<string name="account_actions">Actions du compte</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>
|
</resources>
|
||||||
|
@ -205,4 +205,5 @@
|
|||||||
<string name="action_appinfo_perms">App Infos and permissions</string>
|
<string name="action_appinfo_perms">App Infos and permissions</string>
|
||||||
<string name="restore_all_messages">Restore all messages</string>
|
<string name="restore_all_messages">Restore all messages</string>
|
||||||
<string name="account_actions">Account actions</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>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user