diff --git a/CHANGES.md b/CHANGES.md
index fc8b062fbf..a2c66163e7 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -6,6 +6,7 @@ Features ✨:
Improvements 🙌:
- Add support for `/plain` command (#12)
+ - Detect spaces in password if user fail to login (#1038)
- FTUE: do not display a different color when encrypting message when not in developer mode.
Bugfix 🐛:
diff --git a/vector/src/main/java/im/vector/riotx/features/login/LoginFragment.kt b/vector/src/main/java/im/vector/riotx/features/login/LoginFragment.kt
index 3e45eeb406..01cc19fa5b 100644
--- a/vector/src/main/java/im/vector/riotx/features/login/LoginFragment.kt
+++ b/vector/src/main/java/im/vector/riotx/features/login/LoginFragment.kt
@@ -209,7 +209,14 @@ class LoginFragment @Inject constructor() : AbstractLoginFragment() {
} else {
// Trick to display the error without text.
loginFieldTil.error = " "
- passwordFieldTil.error = errorFormatter.toHumanReadable(state.asyncLoginAction.error)
+ if (error is Failure.ServerError
+ && error.error.code == MatrixError.M_FORBIDDEN
+ && error.error.message == "Invalid password"
+ && spaceInPassword()) {
+ passwordFieldTil.error = getString(R.string.auth_invalid_login_param_space_in_password)
+ } else {
+ passwordFieldTil.error = errorFormatter.toHumanReadable(error)
+ }
}
}
// Success is handled by the LoginActivity
@@ -226,4 +233,9 @@ class LoginFragment @Inject constructor() : AbstractLoginFragment() {
is Success -> Unit
}
}
+
+ /**
+ * Detect if password ends or starts with spaces
+ */
+ private fun spaceInPassword() = passwordField.text.toString().let { it.trim() != it }
}
diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml
index 69d821c0ca..579fdae874 100644
--- a/vector/src/main/res/values/strings_riotX.xml
+++ b/vector/src/main/res/values/strings_riotX.xml
@@ -29,4 +29,5 @@
Sends a message as plain text, without interpreting it as markdown
+ Incorrect username and/or password. The entered password starts or ends with spaces, please check it.