mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 21:48:50 +03:00
Merge pull request #1415 from vector-im/feature/signup_username_digit
Temporary fix to show error when user is creating an account on matrix.org with userId containing only digits (#1410)
This commit is contained in:
commit
40f2d19f81
4 changed files with 11 additions and 4 deletions
|
@ -1,9 +1,6 @@
|
||||||
<component name="ProjectCodeStyleConfiguration">
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
<code_scheme name="Project" version="173">
|
<code_scheme name="Project" version="173">
|
||||||
<option name="RIGHT_MARGIN" value="160" />
|
<option name="RIGHT_MARGIN" value="160" />
|
||||||
<AndroidXmlCodeStyleSettings>
|
|
||||||
<option name="ARRANGEMENT_SETTINGS_MIGRATED_TO_191" value="true" />
|
|
||||||
</AndroidXmlCodeStyleSettings>
|
|
||||||
<JetCodeStyleSettings>
|
<JetCodeStyleSettings>
|
||||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||||
<value>
|
<value>
|
||||||
|
|
|
@ -11,6 +11,7 @@ Improvements 🙌:
|
||||||
|
|
||||||
Bugfix 🐛:
|
Bugfix 🐛:
|
||||||
- Switch theme is not fully taken into account without restarting the app
|
- 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 🗣:
|
Translations 🗣:
|
||||||
-
|
-
|
||||||
|
|
|
@ -49,7 +49,7 @@ internal class DefaultSignOutTask @Inject constructor(
|
||||||
apiCall = signOutAPI.signOut()
|
apiCall = signOutAPI.signOut()
|
||||||
}
|
}
|
||||||
} catch (throwable: Throwable) {
|
} 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
|
if (throwable is Failure.ServerError
|
||||||
&& throwable.httpCode == HttpURLConnection.HTTP_UNAUTHORIZED /* 401 */
|
&& throwable.httpCode == HttpURLConnection.HTTP_UNAUTHORIZED /* 401 */
|
||||||
&& throwable.error.code == MatrixError.M_UNKNOWN_TOKEN) {
|
&& throwable.error.code == MatrixError.M_UNKNOWN_TOKEN) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import androidx.autofill.HintConstants
|
import androidx.autofill.HintConstants
|
||||||
|
import androidx.core.text.isDigitsOnly
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import butterknife.OnClick
|
import butterknife.OnClick
|
||||||
import com.airbnb.mvrx.Fail
|
import com.airbnb.mvrx.Fail
|
||||||
|
@ -53,6 +54,9 @@ class LoginFragment @Inject constructor() : AbstractLoginFragment() {
|
||||||
|
|
||||||
private var passwordShown = false
|
private var passwordShown = false
|
||||||
private var isSignupMode = 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
|
override fun getLayoutResId() = R.layout.fragment_login
|
||||||
|
|
||||||
|
@ -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)
|
loginFieldTil.error = getString(if (isSignupMode) R.string.error_empty_field_choose_user_name else R.string.error_empty_field_enter_user_name)
|
||||||
error++
|
error++
|
||||||
}
|
}
|
||||||
|
if (isSignupMode && isNumericOnlyUserIdForbidden && login.isDigitsOnly()) {
|
||||||
|
loginFieldTil.error = "The homeserver does not accept username with only digits."
|
||||||
|
error++
|
||||||
|
}
|
||||||
if (password.isEmpty()) {
|
if (password.isEmpty()) {
|
||||||
passwordFieldTil.error = getString(if (isSignupMode) R.string.error_empty_field_choose_password else R.string.error_empty_field_your_password)
|
passwordFieldTil.error = getString(if (isSignupMode) R.string.error_empty_field_choose_password else R.string.error_empty_field_your_password)
|
||||||
error++
|
error++
|
||||||
|
@ -227,6 +235,7 @@ class LoginFragment @Inject constructor() : AbstractLoginFragment() {
|
||||||
|
|
||||||
override fun updateWithState(state: LoginViewState) {
|
override fun updateWithState(state: LoginViewState) {
|
||||||
isSignupMode = state.signMode == SignMode.SignUp
|
isSignupMode = state.signMode == SignMode.SignUp
|
||||||
|
isNumericOnlyUserIdForbidden = state.serverType == ServerType.MatrixOrg
|
||||||
|
|
||||||
setupUi(state)
|
setupUi(state)
|
||||||
setupAutoFill(state)
|
setupAutoFill(state)
|
||||||
|
|
Loading…
Reference in a new issue