mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-04 04:57:39 +01:00
handling unverified email as a dialog error in the reset password flow with a friendly error message
This commit is contained in:
parent
e9bd271642
commit
e6df2b39b4
@ -86,6 +86,10 @@ fun Throwable.isInvalidUIAAuth() = this is Failure.ServerError &&
|
||||
fun Throwable.isHomeserverUnavailable() = this is Failure.NetworkConnection &&
|
||||
this.ioException is UnknownHostException
|
||||
|
||||
fun Throwable.isMissingEmailVerification() = this is Failure.ServerError &&
|
||||
error.code == MatrixError.M_UNAUTHORIZED &&
|
||||
error.message == "Unable to get validated threepid"
|
||||
|
||||
/**
|
||||
* Try to convert to a RegistrationFlowResponse. Return null in the cases it's not possible
|
||||
*/
|
||||
|
@ -25,6 +25,7 @@ import org.matrix.android.sdk.api.failure.MatrixError
|
||||
import org.matrix.android.sdk.api.failure.MatrixIdFailure
|
||||
import org.matrix.android.sdk.api.failure.isInvalidPassword
|
||||
import org.matrix.android.sdk.api.failure.isLimitExceededError
|
||||
import org.matrix.android.sdk.api.failure.isMissingEmailVerification
|
||||
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.SocketTimeoutException
|
||||
@ -105,6 +106,9 @@ class DefaultErrorFormatter @Inject constructor(
|
||||
throwable.error.message == "Not allowed to join this room" -> {
|
||||
stringProvider.getString(R.string.room_error_access_unauthorized)
|
||||
}
|
||||
throwable.isMissingEmailVerification() -> {
|
||||
stringProvider.getString(R.string.auth_reset_password_error_unverified)
|
||||
}
|
||||
else -> {
|
||||
throwable.error.message.takeIf { it.isNotEmpty() }
|
||||
?: throwable.error.code.takeIf { it.isNotEmpty() }
|
||||
|
@ -31,6 +31,8 @@ import im.vector.app.core.extensions.setOnImeDoneListener
|
||||
import im.vector.app.databinding.FragmentFtueResetPasswordInputBinding
|
||||
import im.vector.app.features.onboarding.OnboardingAction
|
||||
import im.vector.app.features.onboarding.OnboardingViewState
|
||||
import org.matrix.android.sdk.api.failure.isInvalidPassword
|
||||
import org.matrix.android.sdk.api.failure.isMissingEmailVerification
|
||||
|
||||
@AndroidEntryPoint
|
||||
class FtueAuthResetPasswordEntryFragment : AbstractFtueAuthFragment<FragmentFtueResetPasswordInputBinding>() {
|
||||
@ -61,7 +63,12 @@ class FtueAuthResetPasswordEntryFragment : AbstractFtueAuthFragment<FragmentFtue
|
||||
}
|
||||
|
||||
override fun onError(throwable: Throwable) {
|
||||
views.newPasswordInput.error = errorFormatter.toHumanReadable(throwable)
|
||||
when {
|
||||
throwable.isMissingEmailVerification() -> super.onError(throwable)
|
||||
else -> {
|
||||
views.newPasswordInput.error = errorFormatter.toHumanReadable(throwable)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateWithState(state: OnboardingViewState) {
|
||||
|
@ -524,6 +524,7 @@
|
||||
<string name="auth_recaptcha_message">This homeserver would like to make sure you are not a robot</string>
|
||||
<string name="auth_reset_password_missing_email">The email address linked to your account must be entered.</string>
|
||||
<string name="auth_reset_password_error_unauthorized">Failed to verify email address: make sure you clicked the link in the email</string>
|
||||
<string name="auth_reset_password_error_unverified">Email not verified, check your inbox</string>
|
||||
<string name="auth_accept_policies">"Please review and accept the policies of this homeserver:"</string>
|
||||
|
||||
<!-- Login Screen -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user