Skip to content

Commit

Permalink
Temporary fix to show error when user is creating an account on matri…
Browse files Browse the repository at this point in the history
…x.org with userId containing only digits (#1410)
  • Loading branch information
bmarty committed Jun 3, 2020
1 parent 55bd346 commit 0fd5089
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 0 additions & 3 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Improvements 🙌:

Bugfix 🐛:
- Switch theme is not fully taken into account without restarting the app
- Temporary fix to show error when user is creating an account on matrix.org with userId containing only digits (#1410)

Translations 🗣:
-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.os.Bundle
import android.view.View
import android.view.inputmethod.EditorInfo
import androidx.autofill.HintConstants
import androidx.core.text.isDigitsOnly
import androidx.core.view.isVisible
import butterknife.OnClick
import com.airbnb.mvrx.Fail
Expand Down Expand Up @@ -53,6 +54,9 @@ class LoginFragment @Inject constructor() : AbstractLoginFragment() {

private var passwordShown = false
private var isSignupMode = false
// Temporary patch for https://github.com/vector-im/riotX-android/issues/1410,
// waiting for https://github.com/matrix-org/synapse/issues/7576
private var isNumericOnlyUserIdForbidden = false

override fun getLayoutResId() = R.layout.fragment_login

Expand Down Expand Up @@ -101,6 +105,10 @@ class LoginFragment @Inject constructor() : AbstractLoginFragment() {
loginFieldTil.error = getString(if (isSignupMode) R.string.error_empty_field_choose_user_name else R.string.error_empty_field_enter_user_name)
error++
}
if (isSignupMode && isNumericOnlyUserIdForbidden && login.isDigitsOnly()) {
loginFieldTil.error = "The homeserver does not accept username with only digits."
error++
}
if (password.isEmpty()) {
passwordFieldTil.error = getString(if (isSignupMode) R.string.error_empty_field_choose_password else R.string.error_empty_field_your_password)
error++
Expand Down Expand Up @@ -227,6 +235,7 @@ class LoginFragment @Inject constructor() : AbstractLoginFragment() {

override fun updateWithState(state: LoginViewState) {
isSignupMode = state.signMode == SignMode.SignUp
isNumericOnlyUserIdForbidden = state.serverType == ServerType.MatrixOrg

setupUi(state)
setupAutoFill(state)
Expand Down

0 comments on commit 0fd5089

Please sign in to comment.