Skip to content

Commit

Permalink
Merge pull request #1415 from vector-im/feature/signup_username_digit
Browse files Browse the repository at this point in the history
Temporary fix to show error when user is creating an account on matrix.org with userId containing only digits (#1410)
  • Loading branch information
bmarty authored Jun 3, 2020
2 parents 55bd346 + 2e997f2 commit 40f2d19
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 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 @@ -49,7 +49,7 @@ internal class DefaultSignOutTask @Inject constructor(
apiCall = signOutAPI.signOut()
}
} catch (throwable: Throwable) {
// Maybe due to https://github.com/matrix-org/synapse/issues/5755
// Maybe due to https://github.com/matrix-org/synapse/issues/5756
if (throwable is Failure.ServerError
&& throwable.httpCode == HttpURLConnection.HTTP_UNAUTHORIZED /* 401 */
&& throwable.error.code == MatrixError.M_UNKNOWN_TOKEN) {
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 40f2d19

Please sign in to comment.