mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 17:35:54 +03:00
Login screens: handle mandatory dummy stage automatically
This commit is contained in:
parent
f84ec08847
commit
6cb3c222a9
5 changed files with 20 additions and 12 deletions
|
@ -30,8 +30,9 @@ sealed class Stage(open val mandatory: Boolean) {
|
|||
|
||||
// m.login.token
|
||||
|
||||
// m.login.dummy, never mandatory by definition
|
||||
object Dummy : Stage(false)
|
||||
// m.login.dummy, can be mandatory if there is no other stages. In this case the account cannot be created by just sending a username
|
||||
// and a password, the dummy stage has to be done
|
||||
data class Dummy(override val mandatory: Boolean) : Stage(mandatory)
|
||||
|
||||
// Undocumented yet: m.login.terms
|
||||
data class Terms(override val mandatory: Boolean, val policies: TermPolicies) : Stage(mandatory)
|
||||
|
|
|
@ -81,7 +81,7 @@ fun RegistrationFlowResponse.toFlowResult(): FlowResult {
|
|||
val stage = when (type) {
|
||||
LoginFlowTypes.RECAPTCHA -> Stage.ReCaptcha(isMandatory, ((params?.get(type) as? Map<*, *>)?.get("public_key") as? String)
|
||||
?: "")
|
||||
LoginFlowTypes.DUMMY -> Stage.Dummy
|
||||
LoginFlowTypes.DUMMY -> Stage.Dummy(isMandatory)
|
||||
LoginFlowTypes.TERMS -> Stage.Terms(isMandatory, params?.get(type) as? TermPolicies ?: emptyMap<String, String>())
|
||||
LoginFlowTypes.EMAIL_IDENTITY -> Stage.Email(isMandatory)
|
||||
LoginFlowTypes.MSISDN -> Stage.Msisdn(isMandatory)
|
||||
|
|
|
@ -128,14 +128,14 @@ class LoginActivity : VectorBaseActivity(), ToolbarConfigurable {
|
|||
}
|
||||
is LoginNavigation.OnSendEmailSuccess ->
|
||||
addFragmentToBackstack(R.id.loginFragmentContainer,
|
||||
LoginWaitForEmailFragment::class.java,
|
||||
LoginWaitForEmailFragmentArgument(loginNavigation.email),
|
||||
tag = FRAGMENT_REGISTRATION_STAGE_TAG)
|
||||
LoginWaitForEmailFragment::class.java,
|
||||
LoginWaitForEmailFragmentArgument(loginNavigation.email),
|
||||
tag = FRAGMENT_REGISTRATION_STAGE_TAG)
|
||||
is LoginNavigation.OnSendMsisdnSuccess ->
|
||||
addFragmentToBackstack(R.id.loginFragmentContainer,
|
||||
LoginGenericTextInputFormFragment::class.java,
|
||||
LoginGenericTextInputFormFragmentArgument(TextInputFormFragmentMode.ConfirmMsisdn, true, loginNavigation.msisdn),
|
||||
tag = FRAGMENT_REGISTRATION_STAGE_TAG)
|
||||
LoginGenericTextInputFormFragment::class.java,
|
||||
LoginGenericTextInputFormFragmentArgument(TextInputFormFragmentMode.ConfirmMsisdn, true, loginNavigation.msisdn),
|
||||
tag = FRAGMENT_REGISTRATION_STAGE_TAG)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import im.vector.matrix.android.api.auth.login.LoginWizard
|
|||
import im.vector.matrix.android.api.auth.registration.FlowResult
|
||||
import im.vector.matrix.android.api.auth.registration.RegistrationResult
|
||||
import im.vector.matrix.android.api.auth.registration.RegistrationWizard
|
||||
import im.vector.matrix.android.api.auth.registration.Stage
|
||||
import im.vector.matrix.android.api.session.Session
|
||||
import im.vector.matrix.android.api.util.Cancelable
|
||||
import im.vector.matrix.android.api.util.MatrixCallbackDelegate
|
||||
|
@ -450,8 +451,14 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
|
|||
}
|
||||
|
||||
private fun onFlowResponse(flowResult: FlowResult) {
|
||||
// Notify the user
|
||||
_viewEvents.post(LoginViewEvents.RegistrationFlowResult(flowResult))
|
||||
// If dummy stage is mandatory, and password is already sent, do the dummy stage now
|
||||
if (isRegistrationStarted
|
||||
&& flowResult.missingStages.any { it is Stage.Dummy && it.mandatory }) {
|
||||
handleRegisterDummy()
|
||||
} else {
|
||||
// Notify the user
|
||||
_viewEvents.post(LoginViewEvents.RegistrationFlowResult(flowResult))
|
||||
}
|
||||
}
|
||||
|
||||
private fun onSessionCreated(session: Session) {
|
||||
|
|
|
@ -19,7 +19,7 @@ package im.vector.riotx.features.login
|
|||
import im.vector.matrix.android.api.auth.registration.Stage
|
||||
|
||||
/**
|
||||
* Stage.Other is not supported, as well as any other new stage added to the SDK before it is added to the list below
|
||||
* Stage.Other is not supported, as well as any other new stages added to the SDK before it is added to the list below
|
||||
*/
|
||||
fun Stage.isSupported(): Boolean {
|
||||
return this is Stage.ReCaptcha
|
||||
|
|
Loading…
Reference in a new issue