Merge pull request #2089 from vector-im/feature/dendrite_test

Show M_WEAK_PASSWORD error in the password field
This commit is contained in:
Benoit Marty 2020-09-10 18:10:45 +02:00 committed by GitHub
commit 6f1875c13a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -132,6 +132,8 @@ data class MatrixError(
const val M_CANNOT_LEAVE_SERVER_NOTICE_ROOM = "M_CANNOT_LEAVE_SERVER_NOTICE_ROOM"
/** (Not documented yet) */
const val M_WRONG_ROOM_KEYS_VERSION = "M_WRONG_ROOM_KEYS_VERSION"
/** (Not documented yet) */
const val M_WEAK_PASSWORD = "M_WEAK_PASSWORD"
const val M_TERMS_NOT_SIGNED = "M_TERMS_NOT_SIGNED"

View File

@ -33,13 +33,13 @@ import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.extensions.hideKeyboard
import im.vector.app.core.extensions.showPassword
import im.vector.app.core.extensions.toReducedUrl
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.failure.MatrixError
import org.matrix.android.sdk.api.failure.isInvalidPassword
import io.reactivex.Observable
import io.reactivex.functions.BiFunction
import io.reactivex.rxkotlin.subscribeBy
import kotlinx.android.synthetic.main.fragment_login.*
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.failure.MatrixError
import org.matrix.android.sdk.api.failure.isInvalidPassword
import javax.inject.Inject
/**
@ -234,7 +234,13 @@ class LoginFragment @Inject constructor() : AbstractLoginFragment() {
}
override fun onError(throwable: Throwable) {
loginFieldTil.error = errorFormatter.toHumanReadable(throwable)
// Show M_WEAK_PASSWORD error in the password field
if (throwable is Failure.ServerError
&& throwable.error.code == MatrixError.M_WEAK_PASSWORD) {
passwordFieldTil.error = errorFormatter.toHumanReadable(throwable)
} else {
loginFieldTil.error = errorFormatter.toHumanReadable(throwable)
}
}
override fun updateWithState(state: LoginViewState) {