From 2f892b4ea4d08be93e3f1a5edbf1dd4d0843a39b Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Mon, 20 Aug 2018 14:58:49 +0200 Subject: [PATCH] Handle too many request error on create account form. --- .../comunic/client/data/enums/CreateAccountResult.java | 5 +++++ .../android/comunic/client/data/helpers/AccountHelper.java | 3 +++ .../comunic/client/ui/activities/CreateAccountActivity.java | 5 +++++ app/src/main/res/values/strings.xml | 1 + 4 files changed, 14 insertions(+) diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/enums/CreateAccountResult.java b/app/src/main/java/org/communiquons/android/comunic/client/data/enums/CreateAccountResult.java index f44a159..9af17cc 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/enums/CreateAccountResult.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/enums/CreateAccountResult.java @@ -12,6 +12,11 @@ public enum CreateAccountResult { */ SUCCESS, + /** + * Too many account creation requests + */ + ERROR_TOO_MANY_REQUESTS, + /** * Trying to login with an existing email address */ diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/AccountHelper.java b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/AccountHelper.java index 9accce1..ef63750 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/AccountHelper.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/data/helpers/AccountHelper.java @@ -209,6 +209,9 @@ public class AccountHelper { case 409: return CreateAccountResult.ERROR_EXISTING_EMAIL; + case 429: + return CreateAccountResult.ERROR_TOO_MANY_REQUESTS; + default: return CreateAccountResult.ERROR; diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/CreateAccountActivity.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/CreateAccountActivity.java index 7f51cec..b980efb 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/CreateAccountActivity.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/activities/CreateAccountActivity.java @@ -250,6 +250,11 @@ public class CreateAccountActivity extends AppCompatActivity int message = R.string.err_while_creating_account; switch (result){ + //Too many account creation requests + case ERROR_TOO_MANY_REQUESTS: + message = R.string.err_create_account_too_many_requests; + break; + //Existing email address case ERROR_EXISTING_EMAIL: message = R.string.err_create_account_existing_email; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d3b281e..b135c44 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -234,4 +234,5 @@ Sign in Too many failed login requests. Please try again later… This email address is already associated with an account! + Too many account creation requests. Please try again later...