diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/login/DefaultLoginWizard.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/login/DefaultLoginWizard.kt index c155b91f33..5ba1ae85ec 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/login/DefaultLoginWizard.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/login/DefaultLoginWizard.kt @@ -75,16 +75,16 @@ internal class DefaultLoginWizard( callback: MatrixCallback): Cancelable { val job = GlobalScope.launch(coroutineDispatchers.main) { val sessionOrFailure = runCatching { - authenticate(login, password, deviceName) + loginInternal(login, password, deviceName) } sessionOrFailure.foldToCallback(callback) } return CancelableCoroutine(job) } - private suspend fun authenticate(login: String, - password: String, - deviceName: String) = withContext(coroutineDispatchers.io) { + private suspend fun loginInternal(login: String, + password: String, + deviceName: String) = withContext(coroutineDispatchers.io) { val loginParams = if (Patterns.EMAIL_ADDRESS.matcher(login).matches()) { PasswordLoginParams.thirdPartyIdentifier(ThreePidMedium.EMAIL, login, password, deviceName) } else { 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 84ae268476..f1922e623a 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 @@ -27,6 +27,8 @@ import com.airbnb.mvrx.Loading import com.airbnb.mvrx.Success import com.airbnb.mvrx.withState import com.jakewharton.rxbinding3.widget.textChanges +import im.vector.matrix.android.api.failure.Failure +import im.vector.matrix.android.api.failure.MatrixError import im.vector.riotx.R import im.vector.riotx.core.error.ErrorFormatter import im.vector.riotx.core.extensions.hideKeyboard @@ -199,9 +201,17 @@ class LoginFragment @Inject constructor( renderPasswordField() } is Fail -> { - // Trick to display the error without text. - loginFieldTil.error = " " - passwordFieldTil.error = errorFormatter.toHumanReadable(state.asyncLoginAction.error) + val error = state.asyncLoginAction.error + if (error is Failure.ServerError + && error.error.code == MatrixError.FORBIDDEN + && error.error.message.isEmpty()) { + // Login with email, but email unknown + loginFieldTil.error = getString(R.string.login_login_with_email_error) + } else { + // Trick to display the error without text. + loginFieldTil.error = " " + passwordFieldTil.error = errorFormatter.toHumanReadable(state.asyncLoginAction.error) + } } // Success is handled by the LoginActivity is Success -> Unit diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml index b4ee85adb5..a85aaf1b35 100644 --- a/vector/src/main/res/values/strings_riotX.xml +++ b/vector/src/main/res/values/strings_riotX.xml @@ -59,6 +59,8 @@ Sorry, this server isn’t accepting new accounts. The application is not able to create an account on this homeserver.\n\nDo you want to signup using a web client? + This email is not associated to any account. + Reset password on %1$s A verification email will be sent to your inbox to confirm setting your new password.