From 094190648785271db0a2810150d4d59e82483c17 Mon Sep 17 00:00:00 2001 From: Zafar Date: Sat, 16 May 2020 13:23:06 +0530 Subject: [PATCH 1/2] [EKA-011] Revoke Otp attempt after exceeding invalid otp attempt limit --- features/core/src/main/res/values/strings.xml | 1 + .../ui/fragment/RegistrationOtpFragment.kt | 21 +++++++++++++------ .../ui/fragment/ResetPasswordOtpFragment.kt | 7 +++++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/features/core/src/main/res/values/strings.xml b/features/core/src/main/res/values/strings.xml index 63b6f526..49be6432 100644 --- a/features/core/src/main/res/values/strings.xml +++ b/features/core/src/main/res/values/strings.xml @@ -18,4 +18,5 @@ Hide Registered Successfully OTP request limit exceeded. Please try again after some time. + You have exceeded the invalid attempts limit, Please try later diff --git a/user/registration/src/main/java/in/projecteka/jataayu/registration/ui/fragment/RegistrationOtpFragment.kt b/user/registration/src/main/java/in/projecteka/jataayu/registration/ui/fragment/RegistrationOtpFragment.kt index 6ae4d385..5015da40 100644 --- a/user/registration/src/main/java/in/projecteka/jataayu/registration/ui/fragment/RegistrationOtpFragment.kt +++ b/user/registration/src/main/java/in/projecteka/jataayu/registration/ui/fragment/RegistrationOtpFragment.kt @@ -23,7 +23,9 @@ class RegistrationOtpFragment : BaseFragment() { companion object { const val ERROR_CODE_INVALID_OTP = 1003 + const val ERROR_CODE_OTP_EXPIRED = 1004 const val ERROR_CODE_OTP_LIMIT_EXCEEDED = 1029 + const val EXCEEDED_INVALID_ATTEMPT_LIMIT = 1035 fun newInstance() = RegistrationOtpFragment() } @@ -64,15 +66,22 @@ class RegistrationOtpFragment : BaseFragment() { parentVM.verifyIdentifierResponseLiveData.observe(this, Observer { when (it) { is PartialFailure -> { - if (it.error?.code == ERROR_CODE_INVALID_OTP) { + if (it.error?.code == ERROR_CODE_INVALID_OTP || it.error?.code == EXCEEDED_INVALID_ATTEMPT_LIMIT ) { viewModel.otpText.set(null) } - viewModel.errorLbl.set( - if (it.error?.code == ERROR_CODE_INVALID_OTP) { - getString(R.string.invalid_otp) - } else - it.error?.message + when (it.error?.code) { + ERROR_CODE_INVALID_OTP -> { + getString(R.string.invalid_otp) + } + ERROR_CODE_OTP_EXPIRED -> { + getString(R.string.otp_expired) + } + EXCEEDED_INVALID_ATTEMPT_LIMIT -> { + getString(R.string.exceeded_otp_attempt_limit) + } + else -> it.error?.message + } ) } } diff --git a/user/resetPassword/src/main/java/in/projecteka/resetpassword/ui/fragment/ResetPasswordOtpFragment.kt b/user/resetPassword/src/main/java/in/projecteka/resetpassword/ui/fragment/ResetPasswordOtpFragment.kt index 9ce33ead..c4e1c370 100644 --- a/user/resetPassword/src/main/java/in/projecteka/resetpassword/ui/fragment/ResetPasswordOtpFragment.kt +++ b/user/resetPassword/src/main/java/in/projecteka/resetpassword/ui/fragment/ResetPasswordOtpFragment.kt @@ -33,6 +33,7 @@ class ResetPasswordOtpFragment : BaseFragment() { companion object { private const val ERROR_CODE_INVALID_OTP = 1003 private const val ERROR_CODE_OTP_EXPIRED = 1004 + const val EXCEEDED_INVALID_ATTEMPT_LIMIT = 1035 fun newInstance() = ResetPasswordOtpFragment() private lateinit var snackbar: Snackbar } @@ -73,10 +74,9 @@ class ResetPasswordOtpFragment : BaseFragment() { is Loading -> viewModel.showProgress(it.isLoading) is PartialFailure -> { - if (it.error?.code == ERROR_CODE_INVALID_OTP || it.error?.code == ERROR_CODE_OTP_EXPIRED) { + if (it.error?.code == ERROR_CODE_INVALID_OTP || it.error?.code == ERROR_CODE_OTP_EXPIRED || it.error?.code == EXCEEDED_INVALID_ATTEMPT_LIMIT) { viewModel.otpText.set(null) } - viewModel.errorLbl.set( when (it.error?.code) { ERROR_CODE_INVALID_OTP -> { @@ -85,6 +85,9 @@ class ResetPasswordOtpFragment : BaseFragment() { ERROR_CODE_OTP_EXPIRED -> { getString(R.string.otp_expired) } + EXCEEDED_INVALID_ATTEMPT_LIMIT -> { + getString(R.string.exceeded_otp_attempt_limit) + } else -> it.error?.message } ) From d78406284861731708c1b0990a52274bf33cc977 Mon Sep 17 00:00:00 2001 From: Zafar Date: Sat, 16 May 2020 15:42:58 +0530 Subject: [PATCH 2/2] [EKA-011] revoke otp attempt after exceeding invalid otp attempt limit --- features/core/src/main/res/values/strings.xml | 2 +- .../jataayu/registration/ui/fragment/RegistrationOtpFragment.kt | 2 +- .../resetpassword/ui/fragment/ResetPasswordOtpFragment.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/features/core/src/main/res/values/strings.xml b/features/core/src/main/res/values/strings.xml index d0090961..c5abb6b7 100644 --- a/features/core/src/main/res/values/strings.xml +++ b/features/core/src/main/res/values/strings.xml @@ -21,5 +21,5 @@ Hide Registered Successfully OTP request limit exceeded. Please try again after some time. - You have exceeded the invalid attempts limit, Please try later + You have exceeded the invalid attempts limit, Please try later diff --git a/user/registration/src/main/java/in/projecteka/jataayu/registration/ui/fragment/RegistrationOtpFragment.kt b/user/registration/src/main/java/in/projecteka/jataayu/registration/ui/fragment/RegistrationOtpFragment.kt index 5015da40..77f81a3a 100644 --- a/user/registration/src/main/java/in/projecteka/jataayu/registration/ui/fragment/RegistrationOtpFragment.kt +++ b/user/registration/src/main/java/in/projecteka/jataayu/registration/ui/fragment/RegistrationOtpFragment.kt @@ -78,7 +78,7 @@ class RegistrationOtpFragment : BaseFragment() { getString(R.string.otp_expired) } EXCEEDED_INVALID_ATTEMPT_LIMIT -> { - getString(R.string.exceeded_otp_attempt_limit) + getString(R.string.otp_attempt_limit_exceed) } else -> it.error?.message } diff --git a/user/resetPassword/src/main/java/in/projecteka/resetpassword/ui/fragment/ResetPasswordOtpFragment.kt b/user/resetPassword/src/main/java/in/projecteka/resetpassword/ui/fragment/ResetPasswordOtpFragment.kt index 72e5f26a..31504fb5 100644 --- a/user/resetPassword/src/main/java/in/projecteka/resetpassword/ui/fragment/ResetPasswordOtpFragment.kt +++ b/user/resetPassword/src/main/java/in/projecteka/resetpassword/ui/fragment/ResetPasswordOtpFragment.kt @@ -88,7 +88,7 @@ class ResetPasswordOtpFragment : BaseFragment() { getString(R.string.otp_expired) } EXCEEDED_INVALID_ATTEMPT_LIMIT -> { - getString(R.string.exceeded_otp_attempt_limit) + getString(R.string.otp_attempt_limit_exceed) } else -> it.error?.message }