Skip to content
Snippets Groups Projects
Commit 4fc62fb4 authored by Taras's avatar Taras
Browse files

Add submitUrl param fallback

parent d6a50fa9
No related branches found
No related tags found
No related merge requests found
......@@ -11,3 +11,5 @@ const val DEFAULT_TERMS_NAME = "Terms and Conditions"
const val TERMS_URL_EXTENSION = "_matrix/consent"
const val REGISTRATION_TOKEN_KEY = "org.matrix.msc3231.login.registration_token"
const val VALIDATION_TOKEN_SUBMIT_URL_PREFIX = "_matrix/identity/api/v1/validate/email/submitToken"
......@@ -55,7 +55,8 @@ class ValidateEmailFragment : Fragment(R.layout.validate_email_fragment), HasLoa
}
private fun setupObservers() {
viewModel.sendCodeLiveData.observeResponse(this) { validationCodeSentState() }
viewModel.sendCodeLiveData.observeResponse(this,
success = { validationCodeSentState() })
viewModel.validateEmailLiveData.observeResponse(this)
}
......@@ -64,7 +65,7 @@ class ValidateEmailFragment : Fragment(R.layout.validate_email_fragment), HasLoa
private fun validationCodeSentState() {
showSuccess(getString(R.string.validation_code_sent_to_format, getEmailInput()))
binding.tilValidationCode.visible()
binding.btnValidate.isEnabled = false
binding.btnValidate.isEnabled = binding.tilValidationCode.editText?.text.isNullOrEmpty().not()
}
}
\ No newline at end of file
......@@ -7,12 +7,13 @@ import com.futo.circles.extensions.Response
import com.futo.circles.extensions.launchBg
import com.futo.circles.feature.validate_email.data_source.ValidateEmailDataSource
import org.matrix.android.sdk.api.auth.registration.RegistrationResult
import org.matrix.android.sdk.internal.auth.registration.AddThreePidRegistrationResponse
class ValidateEmailViewModel(
private val dataSource: ValidateEmailDataSource
) : ViewModel() {
val sendCodeLiveData = MutableLiveData<Response<RegistrationResult>>()
val sendCodeLiveData = MutableLiveData<Response<AddThreePidRegistrationResponse>>()
val validateEmailLiveData = SingleEventLiveData<Response<RegistrationResult>>()
......
package com.futo.circles.feature.validate_email.data_source
import com.futo.circles.BuildConfig
import com.futo.circles.core.VALIDATION_TOKEN_SUBMIT_URL_PREFIX
import com.futo.circles.extensions.Response
import com.futo.circles.extensions.createResult
import com.futo.circles.feature.sign_up.data_source.SignUpDataSource
import com.futo.circles.provider.MatrixInstanceProvider
import org.matrix.android.sdk.api.auth.registration.RegisterThreePid
import org.matrix.android.sdk.api.auth.registration.RegistrationResult
import org.matrix.android.sdk.internal.auth.registration.AddThreePidRegistrationResponse
class ValidateEmailDataSource(
private val signUpDataSource: SignUpDataSource
......@@ -15,12 +18,17 @@ class ValidateEmailDataSource(
MatrixInstanceProvider.matrix.authenticationService().getRegistrationWizard()
}
suspend fun sendValidationCode(email: String): Response<RegistrationResult> =
suspend fun sendValidationCode(email: String): Response<AddThreePidRegistrationResponse> =
createResult { wizard.addThreePid(RegisterThreePid.Email(email)) }
suspend fun validateEmail(code: String): Response<RegistrationResult> {
val result = createResult { wizard.handleValidateThreePid(code) }
val result = createResult {
wizard.handleValidateThreePid(
code,
BuildConfig.MATRIX_HOME_SERVER_URL + VALIDATION_TOKEN_SUBMIT_URL_PREFIX
)
}
(result as? Response.Success)?.let { signUpDataSource.stageCompleted(result.data) }
return result
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment