mifos-mobile: Toast message in case of wrong credentials

Summary:

If a user enters a wrong username or password then currently the toast being displayed is Inavalid authentication details passed in api request . I believe this should be changed to something more meaningful to the user such as Incorrect username or password or Unable to authenticate user

Steps to reproduce:

  • enter either a wrong username or a wrong password at the time of login

Device and Android version: Device : Samsung M11 Android : 11

Screenshots:

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 29 (8 by maintainers)

Most upvoted comments

Hey guys, thank you for your valuable input! @RobustMj open a PR and then let’s see the whole picture first.

Hi @gururani-abhishek that wont be needed all @RobustMj needs to do is change the line 110 of LoginActivity.kt with an appropriate message in all the languages. (Use a Toaster and do not hardcode the string ) However even if you make these changes and allow support for multiple languages you won’t be able to check the Toaster message when you switch to any other language as explained in the issue #1997 .

That’s cool, but I was digging to the root of the issue, right where the exception is received.

@jawidMuhammadi should i raise PR?

Hi @gururani-abhishek that wont be needed all @RobustMj needs to do is change the line 110 of LoginActivity.kt with an appropriate message in all the languages. (Use a Toaster and do not hardcode the string ) However even if you make these changes and allow support for multiple languages you won’t be able to check the Toaster message when you switch to any other language as explained in the issue #1997 .

i added the toast for each of those error “Invalid username” and “Invalid password” in all languages using string but the very first toast “Invalid authentication details were passed in api request” still showed then i commented showToast and lLogin and it works now .

Hey @RobustMj, I ran the application, and in the Logcat(attaching the screenshot below) found that this Toast text(“Invalid authentication details were passed in api request”) is being returned as the response body in OkHttp response when either of “username” and “password” are wrong.

Screenshot 2023-03-18 at 15 51 25

If you want to change the toast message to a custom error text(what Jawid suggested), you need to put a "if"condition when the OkHttp exception code is = 401 and then have to provide your own custom error text.

These points might help you to solve this issue :

  1. In LoginActivity.kt inside onLoginClicked(), “username” and “password” are passed to login() of LoginPresenter.kt class.
  2. Inside login() in try-catch block, you can put an “if” condition for the response code = 401 which corresponds to invalid username and password exception. eg : if(e.code == 401) mvpView?.showMessage(“Invalid username or password”), I’m just hardcoding it right now but you should put an entry of this error in string.xml and also translate it to other languages.

I’m looping @jawidMuhammadi, so that whenever he finds time he can confirm this : )

@RobustMj Tag me if you face any issue/s while dealing with this, I’ll be more than happy to help.