mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
Login screens: login with unknown email
This commit is contained in:
parent
7e1a279fd9
commit
91fcf428dd
3 changed files with 19 additions and 7 deletions
|
@ -75,14 +75,14 @@ internal class DefaultLoginWizard(
|
|||
callback: MatrixCallback<Session>): Cancelable {
|
||||
val job = GlobalScope.launch(coroutineDispatchers.main) {
|
||||
val sessionOrFailure = runCatching {
|
||||
authenticate(login, password, deviceName)
|
||||
loginInternal(login, password, deviceName)
|
||||
}
|
||||
sessionOrFailure.foldToCallback(callback)
|
||||
}
|
||||
return CancelableCoroutine(job)
|
||||
}
|
||||
|
||||
private suspend fun authenticate(login: String,
|
||||
private suspend fun loginInternal(login: String,
|
||||
password: String,
|
||||
deviceName: String) = withContext(coroutineDispatchers.io) {
|
||||
val loginParams = if (Patterns.EMAIL_ADDRESS.matcher(login).matches()) {
|
||||
|
|
|
@ -27,6 +27,8 @@ import com.airbnb.mvrx.Loading
|
|||
import com.airbnb.mvrx.Success
|
||||
import com.airbnb.mvrx.withState
|
||||
import com.jakewharton.rxbinding3.widget.textChanges
|
||||
import im.vector.matrix.android.api.failure.Failure
|
||||
import im.vector.matrix.android.api.failure.MatrixError
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.error.ErrorFormatter
|
||||
import im.vector.riotx.core.extensions.hideKeyboard
|
||||
|
@ -199,10 +201,18 @@ class LoginFragment @Inject constructor(
|
|||
renderPasswordField()
|
||||
}
|
||||
is Fail -> {
|
||||
val error = state.asyncLoginAction.error
|
||||
if (error is Failure.ServerError
|
||||
&& error.error.code == MatrixError.FORBIDDEN
|
||||
&& error.error.message.isEmpty()) {
|
||||
// Login with email, but email unknown
|
||||
loginFieldTil.error = getString(R.string.login_login_with_email_error)
|
||||
} else {
|
||||
// Trick to display the error without text.
|
||||
loginFieldTil.error = " "
|
||||
passwordFieldTil.error = errorFormatter.toHumanReadable(state.asyncLoginAction.error)
|
||||
}
|
||||
}
|
||||
// Success is handled by the LoginActivity
|
||||
is Success -> Unit
|
||||
}
|
||||
|
|
|
@ -59,6 +59,8 @@
|
|||
<string name="login_registration_disabled">Sorry, this server isn’t accepting new accounts.</string>
|
||||
<string name="login_registration_not_supported">The application is not able to create an account on this homeserver.\n\nDo you want to signup using a web client?</string>
|
||||
|
||||
<string name="login_login_with_email_error">This email is not associated to any account.</string>
|
||||
|
||||
<!-- Replaced string is the homeserver url -->
|
||||
<string name="login_reset_password_on">Reset password on %1$s</string>
|
||||
<string name="login_reset_password_notice">A verification email will be sent to your inbox to confirm setting your new password.</string>
|
||||
|
|
Loading…
Reference in a new issue