diff options
author | Parménides GV <parmegv@sdf.org> | 2014-05-08 10:37:14 +0200 |
---|---|---|
committer | Parménides GV <parmegv@sdf.org> | 2014-05-08 10:37:14 +0200 |
commit | e08177035e65ea35249310bb963143a122a17ec7 (patch) | |
tree | b9e15881a0704820b6c73f5a0a5836b630915efd /app/src/debug/java/se/leap | |
parent | 6d9770518b0d94931e9521b72131516a841b193f (diff) |
Error messages fetched directly from api message.
This has the problem of localized messages. irc log questioning:
May 8th 2014
08:12 <@parmegv> mm, I was thinking... I was rephrasing the error messages given by our api during authentication
08:13 <@parmegv> I thought why should I rephrase it and think twice
08:13 <@parmegv> so now I'm just "pretty printing" the error message given by the api
08:13 <@parmegv> but that has a problem: they aren't localized
08:14 <@parmegv> would implementing a localized version of our error messages be useful?
Diffstat (limited to 'app/src/debug/java/se/leap')
-rw-r--r-- | app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java index 8481bf08..dc5b3876 100644 --- a/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java +++ b/app/src/debug/java/se/leap/bitmaskclient/ProviderAPI.java @@ -218,16 +218,9 @@ public class ProviderAPI extends IntentService { BigInteger password_verifier = client.calculateV(username, password, salt); /* Send to the server */ JSONObject result = sendNewUserDataToSRPServer(authentication_server, username, new BigInteger(1, salt).toString(16), password_verifier.toString(16)); - if(result.has(ERRORS)) { - session_id_bundle.putBoolean(RESULT_KEY, false); - try { - // {"errors":{"login":["has already been taken","has already been taken"]}} - session_id_bundle.putString(getResources().getString(R.string.user_message), result.getJSONObject(ERRORS).toString()); - session_id_bundle.putString(LogInDialog.USERNAME, username); - } catch(JSONException e) { - e.printStackTrace(); - } - } + if(result.has(ERRORS)) + session_id_bundle = authFailedNotification(result, username); + Log.d(TAG, result.toString()); broadcast_progress(progress++); } else { @@ -318,11 +311,14 @@ public class ProviderAPI extends IntentService { } private Bundle authFailedNotification(JSONObject result, String username) { - Log.d(TAG, "authFailedNotification("+ result +")"); Bundle user_notification_bundle = new Bundle(); try{ - user_notification_bundle.putString(getResources().getString(R.string.user_message), result.getJSONObject(ERRORS).toString()); + JSONObject error_message = result.getJSONObject(ERRORS); + String error_type = error_message.keys().next().toString(); + String message = error_message.get(error_type).toString(); + user_notification_bundle.putString(getResources().getString(R.string.user_message), message); } catch(JSONException e) {} + if(!username.isEmpty()) user_notification_bundle.putString(LogInDialog.USERNAME, username); user_notification_bundle.putBoolean(RESULT_KEY, false); |