Using /register/available also fixes #1410

(See https://github.com/matrix-org/synapse/pull/7625)
This commit is contained in:
Benoit Marty 2021-04-29 17:02:14 +02:00
parent c09f7e0d7d
commit b3ac1a1e8b
5 changed files with 1 additions and 27 deletions

View file

@ -6,7 +6,7 @@ Features ✨:
Improvements 🙌: Improvements 🙌:
- Add ability to install APK from directly from Element (#2381) - Add ability to install APK from directly from Element (#2381)
- Improve login/register flow (#2585, #3172) - Improve login/register flow (#1410, #2585, #3172)
Bugfix 🐛: Bugfix 🐛:
- Message states cosmetic changes (#3007) - Message states cosmetic changes (#3007)

View file

@ -42,10 +42,6 @@ import javax.inject.Inject
*/ */
class LoginFragmentSignupUsername2 @Inject constructor() : AbstractSSOLoginFragment2<FragmentLoginSignupUsername2Binding>() { class LoginFragmentSignupUsername2 @Inject constructor() : AbstractSSOLoginFragment2<FragmentLoginSignupUsername2Binding>() {
// 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 getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLoginSignupUsername2Binding { override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLoginSignupUsername2Binding {
return FragmentLoginSignupUsername2Binding.inflate(inflater, container, false) return FragmentLoginSignupUsername2Binding.inflate(inflater, container, false)
} }
@ -79,10 +75,6 @@ class LoginFragmentSignupUsername2 @Inject constructor() : AbstractSSOLoginFragm
views.loginFieldTil.error = getString(R.string.error_empty_field_choose_user_name) views.loginFieldTil.error = getString(R.string.error_empty_field_choose_user_name)
error++ error++
} }
if (isNumericOnlyUserIdForbidden && login.isDigitsOnly()) {
views.loginFieldTil.error = "The homeserver does not accept username with only digits."
error++
}
if (error == 0) { if (error == 0) {
loginViewModel.handle(LoginAction2.SetUserName(login)) loginViewModel.handle(LoginAction2.SetUserName(login))
@ -138,8 +130,6 @@ class LoginFragmentSignupUsername2 @Inject constructor() : AbstractSSOLoginFragm
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
override fun updateWithState(state: LoginViewState2) { override fun updateWithState(state: LoginViewState2) {
isNumericOnlyUserIdForbidden = state.isNumericOnlyUserIdForbidden
setupUi(state) setupUi(state)
} }
} }

View file

@ -51,10 +51,6 @@ class LoginFragmentToAny2 @Inject constructor() : AbstractSSOLoginFragment2<Frag
private var passwordShown = false private var passwordShown = 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 getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLoginSigninToAny2Binding { override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentLoginSigninToAny2Binding {
return FragmentLoginSigninToAny2Binding.inflate(inflater, container, false) return FragmentLoginSigninToAny2Binding.inflate(inflater, container, false)
} }
@ -104,10 +100,6 @@ class LoginFragmentToAny2 @Inject constructor() : AbstractSSOLoginFragment2<Frag
views.loginFieldTil.error = getString(R.string.error_empty_field_enter_user_name) views.loginFieldTil.error = getString(R.string.error_empty_field_enter_user_name)
error++ error++
} }
if (isNumericOnlyUserIdForbidden && login.isDigitsOnly()) {
views.loginFieldTil.error = "The homeserver does not accept username with only digits."
error++
}
if (password.isEmpty()) { if (password.isEmpty()) {
views.passwordFieldTil.error = getString(R.string.error_empty_field_your_password) views.passwordFieldTil.error = getString(R.string.error_empty_field_your_password)
error++ error++
@ -213,8 +205,6 @@ class LoginFragmentToAny2 @Inject constructor() : AbstractSSOLoginFragment2<Frag
} }
override fun updateWithState(state: LoginViewState2) { override fun updateWithState(state: LoginViewState2) {
isNumericOnlyUserIdForbidden = state.isNumericOnlyUserIdForbidden
setupUi(state) setupUi(state)
if (state.isLoading) { if (state.isLoading) {

View file

@ -224,7 +224,6 @@ class LoginViewModel2 @AssistedInject constructor(
loginMode = LoginMode.Sso(action.ssoIdentityProviders), loginMode = LoginMode.Sso(action.ssoIdentityProviders),
homeServerUrlFromUser = action.homeServerUrl, homeServerUrlFromUser = action.homeServerUrl,
homeServerUrl = action.homeServerUrl, homeServerUrl = action.homeServerUrl,
isNumericOnlyUserIdForbidden = action.homeServerUrl == matrixOrgUrl,
deviceId = action.deviceId deviceId = action.deviceId
) )
} }
@ -662,7 +661,6 @@ class LoginViewModel2 @AssistedInject constructor(
isLoading = false, isLoading = false,
homeServerUrlFromUser = urlFromUser, homeServerUrlFromUser = urlFromUser,
homeServerUrl = data.homeServerUrl, homeServerUrl = data.homeServerUrl,
isNumericOnlyUserIdForbidden = urlFromUser == matrixOrgUrl,
loginMode = loginMode loginMode = loginMode
) )
} }
@ -818,7 +816,6 @@ class LoginViewModel2 @AssistedInject constructor(
isLoading = false, isLoading = false,
homeServerUrlFromUser = homeServerConnectionConfig.homeServerUri.toString(), homeServerUrlFromUser = homeServerConnectionConfig.homeServerUri.toString(),
homeServerUrl = data.homeServerUrl, homeServerUrl = data.homeServerUrl,
isNumericOnlyUserIdForbidden = homeServerConnectionConfig.homeServerUri.toString() == matrixOrgUrl,
loginMode = loginMode loginMode = loginMode
) )
} }

View file

@ -49,9 +49,6 @@ data class LoginViewState2(
// Network result // Network result
val loginProfileInfo: Async<LoginProfileInfo> = Uninitialized, val loginProfileInfo: Async<LoginProfileInfo> = Uninitialized,
// True on Matrix.org
val isNumericOnlyUserIdForbidden: Boolean = false,
// Network result // Network result
@PersistState @PersistState
val loginMode: LoginMode = LoginMode.Unknown, val loginMode: LoginMode = LoginMode.Unknown,