Login screens: rename a few classes and packages

This commit is contained in:
Benoit Marty 2019-11-21 22:36:16 +01:00
parent be95542110
commit a3111dc2d8
19 changed files with 95 additions and 175 deletions

View file

@ -21,7 +21,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.GrantPermissionRule
import im.vector.matrix.android.InstrumentedTest
import im.vector.matrix.android.OkReplayRuleChainNoActivity
import im.vector.matrix.android.api.auth.Authenticator
import im.vector.matrix.android.api.auth.AuthenticationService
import okreplay.*
import org.junit.ClassRule
import org.junit.Rule
@ -29,9 +29,9 @@ import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
internal class AuthenticatorTest : InstrumentedTest {
internal class AuthenticationServiceTest : InstrumentedTest {
lateinit var authenticator: Authenticator
lateinit var authenticationService: AuthenticationService
lateinit var okReplayInterceptor: OkReplayInterceptor
private val okReplayConfig = OkReplayConfig.Builder()

View file

@ -22,8 +22,7 @@ import androidx.work.Configuration
import androidx.work.WorkManager
import com.zhuinden.monarchy.Monarchy
import im.vector.matrix.android.BuildConfig
import im.vector.matrix.android.api.auth.Authenticator
import im.vector.matrix.android.api.auth.registration.RegistrationService
import im.vector.matrix.android.api.auth.AuthenticationService
import im.vector.matrix.android.internal.SessionManager
import im.vector.matrix.android.internal.di.DaggerMatrixComponent
import im.vector.matrix.android.internal.network.UserAgentHolder
@ -47,8 +46,7 @@ data class MatrixConfiguration(
*/
class Matrix private constructor(context: Context, matrixConfiguration: MatrixConfiguration) {
@Inject internal lateinit var authenticator: Authenticator
@Inject internal lateinit var registrationService: RegistrationService
@Inject internal lateinit var authenticationService: AuthenticationService
@Inject internal lateinit var userAgentHolder: UserAgentHolder
@Inject internal lateinit var backgroundDetectionObserver: BackgroundDetectionObserver
@Inject internal lateinit var olmManager: OlmManager
@ -66,12 +64,8 @@ class Matrix private constructor(context: Context, matrixConfiguration: MatrixCo
fun getUserAgent() = userAgentHolder.userAgent
fun authenticator(): Authenticator {
return authenticator
}
fun registrationService(): RegistrationService {
return registrationService
fun authenticationService(): AuthenticationService {
return authenticationService
}
companion object {

View file

@ -20,14 +20,16 @@ import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.api.auth.data.Credentials
import im.vector.matrix.android.api.auth.data.HomeServerConnectionConfig
import im.vector.matrix.android.api.auth.data.SessionParams
import im.vector.matrix.android.api.auth.login.LoginWizard
import im.vector.matrix.android.api.auth.registration.RegistrationWizard
import im.vector.matrix.android.api.session.Session
import im.vector.matrix.android.api.util.Cancelable
import im.vector.matrix.android.internal.auth.data.LoginFlowResponse
/**
* This interface defines methods to authenticate to a matrix server.
* This interface defines methods to authenticate or to create an account to a matrix server.
*/
interface Authenticator {
interface AuthenticationService {
/**
* Request the supported login flows for this homeserver
@ -35,10 +37,15 @@ interface Authenticator {
fun getLoginFlow(homeServerConnectionConfig: HomeServerConnectionConfig, callback: MatrixCallback<LoginFlowResponse>): Cancelable
/**
* Return an AuthenticationWizard
* Return an LoginWizard
* @param homeServerConnectionConfig this param is used to request the Homeserver
*/
fun createAuthenticationWizard(homeServerConnectionConfig: HomeServerConnectionConfig): AuthenticationWizard
fun createLoginWizard(homeServerConnectionConfig: HomeServerConnectionConfig): LoginWizard
/**
* Return a RegistrationWizard, to create an matrix account on a homeserver
*/
fun getOrCreateRegistrationWizard(homeServerConnectionConfig: HomeServerConnectionConfig): RegistrationWizard
/**
* Check if there is an authenticated [Session].

View file

@ -25,7 +25,7 @@ import okhttp3.TlsVersion
/**
* This data class holds how to connect to a specific Homeserver.
* It's used with [im.vector.matrix.android.api.auth.Authenticator] class.
* It's used with [im.vector.matrix.android.api.auth.AuthenticationService] class.
* You should use the [Builder] to create one.
*/
@JsonClass(generateAdapter = true)

View file

@ -14,13 +14,13 @@
* limitations under the License.
*/
package im.vector.matrix.android.api.auth
package im.vector.matrix.android.api.auth.login
import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.api.session.Session
import im.vector.matrix.android.api.util.Cancelable
interface AuthenticationWizard {
interface LoginWizard {
/**
* @param login the login field
@ -29,10 +29,10 @@ interface AuthenticationWizard {
* @param callback the matrix callback on which you'll receive the result of authentication.
* @return return a [Cancelable]
*/
fun authenticate(login: String,
password: String,
deviceName: String,
callback: MatrixCallback<Session>): Cancelable
fun login(login: String,
password: String,
deviceName: String,
callback: MatrixCallback<Session>): Cancelable
/**
* Reset user password

View file

@ -1,24 +0,0 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.matrix.android.api.auth.registration
import im.vector.matrix.android.api.auth.data.HomeServerConnectionConfig
interface RegistrationService {
fun getOrCreateRegistrationWizard(homeServerConnectionConfig: HomeServerConnectionConfig): RegistrationWizard
}

View file

@ -20,7 +20,7 @@ import im.vector.matrix.android.api.auth.data.Credentials
import im.vector.matrix.android.internal.auth.data.LoginFlowResponse
import im.vector.matrix.android.internal.auth.data.PasswordLoginParams
import im.vector.matrix.android.internal.auth.registration.*
import im.vector.matrix.android.internal.auth.signin.ResetPasswordMailConfirmed
import im.vector.matrix.android.internal.auth.login.ResetPasswordMailConfirmed
import im.vector.matrix.android.internal.network.NetworkConstants
import retrofit2.Call
import retrofit2.http.*

View file

@ -20,11 +20,9 @@ import android.content.Context
import dagger.Binds
import dagger.Module
import dagger.Provides
import im.vector.matrix.android.api.auth.Authenticator
import im.vector.matrix.android.api.auth.registration.RegistrationService
import im.vector.matrix.android.api.auth.AuthenticationService
import im.vector.matrix.android.internal.auth.db.AuthRealmModule
import im.vector.matrix.android.internal.auth.db.RealmSessionParamsStore
import im.vector.matrix.android.internal.auth.registration.DefaultRegistrationService
import im.vector.matrix.android.internal.database.RealmKeysUtils
import im.vector.matrix.android.internal.di.AuthDatabase
import io.realm.RealmConfiguration
@ -61,8 +59,5 @@ internal abstract class AuthModule {
abstract fun bindSessionParamsStore(sessionParamsStore: RealmSessionParamsStore): SessionParamsStore
@Binds
abstract fun bindAuthenticator(authenticator: DefaultAuthenticator): Authenticator
@Binds
abstract fun bindRegistrationService(service: DefaultRegistrationService): RegistrationService
abstract fun bindAuthenticationService(authenticationService: DefaultAuthenticationService): AuthenticationService
}

View file

@ -18,15 +18,18 @@ package im.vector.matrix.android.internal.auth
import dagger.Lazy
import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.api.auth.AuthenticationWizard
import im.vector.matrix.android.api.auth.Authenticator
import im.vector.matrix.android.api.auth.AuthenticationService
import im.vector.matrix.android.api.auth.data.Credentials
import im.vector.matrix.android.api.auth.data.HomeServerConnectionConfig
import im.vector.matrix.android.api.auth.data.SessionParams
import im.vector.matrix.android.api.auth.login.LoginWizard
import im.vector.matrix.android.api.auth.registration.RegistrationWizard
import im.vector.matrix.android.api.session.Session
import im.vector.matrix.android.api.util.Cancelable
import im.vector.matrix.android.internal.SessionManager
import im.vector.matrix.android.internal.auth.data.LoginFlowResponse
import im.vector.matrix.android.internal.auth.login.DefaultLoginWizard
import im.vector.matrix.android.internal.auth.registration.DefaultRegistrationWizard
import im.vector.matrix.android.internal.di.Unauthenticated
import im.vector.matrix.android.internal.extensions.foldToCallback
import im.vector.matrix.android.internal.network.RetrofitFactory
@ -39,13 +42,13 @@ import kotlinx.coroutines.withContext
import okhttp3.OkHttpClient
import javax.inject.Inject
internal class DefaultAuthenticator @Inject constructor(@Unauthenticated
private val okHttpClient: Lazy<OkHttpClient>,
private val retrofitFactory: RetrofitFactory,
private val coroutineDispatchers: MatrixCoroutineDispatchers,
private val sessionParamsStore: SessionParamsStore,
private val sessionManager: SessionManager
) : Authenticator {
internal class DefaultAuthenticationService @Inject constructor(@Unauthenticated
private val okHttpClient: Lazy<OkHttpClient>,
private val retrofitFactory: RetrofitFactory,
private val coroutineDispatchers: MatrixCoroutineDispatchers,
private val sessionParamsStore: SessionParamsStore,
private val sessionManager: SessionManager
) : AuthenticationService {
override fun hasAuthenticatedSessions(): Boolean {
return sessionParamsStore.getLast() != null
@ -80,8 +83,18 @@ internal class DefaultAuthenticator @Inject constructor(@Unauthenticated
}
}
override fun createAuthenticationWizard(homeServerConnectionConfig: HomeServerConnectionConfig): AuthenticationWizard {
return DefaultAuthenticationWizard(
override fun getOrCreateRegistrationWizard(homeServerConnectionConfig: HomeServerConnectionConfig): RegistrationWizard {
// TODO Persist the wizard?
return DefaultRegistrationWizard(homeServerConnectionConfig,
okHttpClient,
retrofitFactory,
coroutineDispatchers,
sessionParamsStore,
sessionManager)
}
override fun createLoginWizard(homeServerConnectionConfig: HomeServerConnectionConfig): LoginWizard {
return DefaultLoginWizard(
homeServerConnectionConfig,
coroutineDispatchers,
sessionParamsStore,

View file

@ -14,26 +14,27 @@
* limitations under the License.
*/
package im.vector.matrix.android.internal.auth
package im.vector.matrix.android.internal.auth.login
import android.util.Patterns
import dagger.Lazy
import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.api.auth.AuthenticationWizard
import im.vector.matrix.android.api.auth.data.Credentials
import im.vector.matrix.android.api.auth.data.HomeServerConnectionConfig
import im.vector.matrix.android.api.auth.data.SessionParams
import im.vector.matrix.android.api.auth.login.LoginWizard
import im.vector.matrix.android.api.auth.registration.RegisterThreePid
import im.vector.matrix.android.api.session.Session
import im.vector.matrix.android.api.util.Cancelable
import im.vector.matrix.android.api.util.NoOpCancellable
import im.vector.matrix.android.internal.SessionManager
import im.vector.matrix.android.internal.auth.AuthAPI
import im.vector.matrix.android.internal.auth.SessionParamsStore
import im.vector.matrix.android.internal.auth.data.PasswordLoginParams
import im.vector.matrix.android.internal.auth.data.ThreePidMedium
import im.vector.matrix.android.internal.auth.registration.AddThreePidRegistrationParams
import im.vector.matrix.android.internal.auth.registration.AddThreePidRegistrationResponse
import im.vector.matrix.android.internal.auth.registration.RegisterAddThreePidTask
import im.vector.matrix.android.internal.auth.signin.ResetPasswordMailConfirmed
import im.vector.matrix.android.internal.extensions.foldToCallback
import im.vector.matrix.android.internal.network.RetrofitFactory
import im.vector.matrix.android.internal.network.executeRequest
@ -51,14 +52,14 @@ internal data class ResetPasswordData(
val addThreePidRegistrationResponse: AddThreePidRegistrationResponse
)
internal class DefaultAuthenticationWizard(
internal class DefaultLoginWizard(
private val homeServerConnectionConfig: HomeServerConnectionConfig,
private val coroutineDispatchers: MatrixCoroutineDispatchers,
private val sessionParamsStore: SessionParamsStore,
private val sessionManager: SessionManager,
retrofitFactory: RetrofitFactory,
okHttpClient: Lazy<OkHttpClient>
) : AuthenticationWizard {
) : LoginWizard {
private var clientSecret = UUID.randomUUID().toString()
private var sendAttempt = 0
@ -68,10 +69,10 @@ internal class DefaultAuthenticationWizard(
private val authAPI = retrofitFactory.create(okHttpClient, homeServerConnectionConfig.homeServerUri.toString())
.create(AuthAPI::class.java)
override fun authenticate(login: String,
password: String,
deviceName: String,
callback: MatrixCallback<Session>): Cancelable {
override fun login(login: String,
password: String,
deviceName: String,
callback: MatrixCallback<Session>): Cancelable {
val job = GlobalScope.launch(coroutineDispatchers.main) {
val sessionOrFailure = runCatching {
authenticate(login, password, deviceName)

View file

@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.matrix.android.internal.auth.signin
package im.vector.matrix.android.internal.auth.login
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

View file

@ -1,47 +0,0 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.matrix.android.internal.auth.registration
import dagger.Lazy
import im.vector.matrix.android.api.auth.data.HomeServerConnectionConfig
import im.vector.matrix.android.api.auth.registration.RegistrationService
import im.vector.matrix.android.api.auth.registration.RegistrationWizard
import im.vector.matrix.android.internal.SessionManager
import im.vector.matrix.android.internal.auth.SessionParamsStore
import im.vector.matrix.android.internal.di.Unauthenticated
import im.vector.matrix.android.internal.network.RetrofitFactory
import im.vector.matrix.android.internal.util.MatrixCoroutineDispatchers
import okhttp3.OkHttpClient
import javax.inject.Inject
internal class DefaultRegistrationService @Inject constructor(@Unauthenticated
private val okHttpClient: Lazy<OkHttpClient>,
private val retrofitFactory: RetrofitFactory,
private val coroutineDispatchers: MatrixCoroutineDispatchers,
private val sessionParamsStore: SessionParamsStore,
private val sessionManager: SessionManager) : RegistrationService {
override fun getOrCreateRegistrationWizard(homeServerConnectionConfig: HomeServerConnectionConfig): RegistrationWizard {
// TODO Persist the wizard?
return DefaultRegistrationWizard(homeServerConnectionConfig,
okHttpClient,
retrofitFactory,
coroutineDispatchers,
sessionParamsStore,
sessionManager)
}
}

View file

@ -22,8 +22,7 @@ import com.squareup.moshi.Moshi
import dagger.BindsInstance
import dagger.Component
import im.vector.matrix.android.api.Matrix
import im.vector.matrix.android.api.auth.Authenticator
import im.vector.matrix.android.api.auth.registration.RegistrationService
import im.vector.matrix.android.api.auth.AuthenticationService
import im.vector.matrix.android.internal.SessionManager
import im.vector.matrix.android.internal.auth.AuthModule
import im.vector.matrix.android.internal.auth.SessionParamsStore
@ -45,9 +44,7 @@ internal interface MatrixComponent {
@Unauthenticated
fun okHttpClient(): OkHttpClient
fun authenticator(): Authenticator
fun registrationService(): RegistrationService
fun authenticationService(): AuthenticationService
fun context(): Context

View file

@ -36,7 +36,7 @@ import com.github.piasy.biv.BigImageViewer
import com.github.piasy.biv.loader.glide.GlideImageLoader
import im.vector.matrix.android.api.Matrix
import im.vector.matrix.android.api.MatrixConfiguration
import im.vector.matrix.android.api.auth.Authenticator
import im.vector.matrix.android.api.auth.AuthenticationService
import im.vector.riotx.core.di.ActiveSessionHolder
import im.vector.riotx.core.di.DaggerVectorComponent
import im.vector.riotx.core.di.HasVectorInjector
@ -63,7 +63,7 @@ class VectorApplication : Application(), HasVectorInjector, MatrixConfiguration.
lateinit var appContext: Context
// font thread handler
@Inject lateinit var authenticator: Authenticator
@Inject lateinit var authenticationService: AuthenticationService
@Inject lateinit var vectorConfiguration: VectorConfiguration
@Inject lateinit var emojiCompatFontProvider: EmojiCompatFontProvider
@Inject lateinit var emojiCompatWrapper: EmojiCompatWrapper
@ -115,8 +115,8 @@ class VectorApplication : Application(), HasVectorInjector, MatrixConfiguration.
emojiCompatWrapper.init(fontRequest)
notificationUtils.createNotificationChannels()
if (authenticator.hasAuthenticatedSessions() && !activeSessionHolder.hasActiveSession()) {
val lastAuthenticatedSession = authenticator.getLastAuthenticatedSession()!!
if (authenticationService.hasAuthenticatedSessions() && !activeSessionHolder.hasActiveSession()) {
val lastAuthenticatedSession = authenticationService.getLastAuthenticatedSession()!!
activeSessionHolder.setActiveSession(lastAuthenticatedSession)
lastAuthenticatedSession.configureAndStart(pushRuleTriggerListener, sessionListener)
}

View file

@ -17,7 +17,7 @@
package im.vector.riotx.core.di
import arrow.core.Option
import im.vector.matrix.android.api.auth.Authenticator
import im.vector.matrix.android.api.auth.AuthenticationService
import im.vector.matrix.android.api.session.Session
import im.vector.riotx.ActiveSessionDataSource
import im.vector.riotx.features.crypto.keysrequest.KeyRequestHandler
@ -27,7 +27,7 @@ import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class ActiveSessionHolder @Inject constructor(private val authenticator: Authenticator,
class ActiveSessionHolder @Inject constructor(private val authenticationService: AuthenticationService,
private val sessionObservableStore: ActiveSessionDataSource,
private val keyRequestHandler: KeyRequestHandler,
private val incomingVerificationRequestHandler: IncomingVerificationRequestHandler
@ -64,7 +64,7 @@ class ActiveSessionHolder @Inject constructor(private val authenticator: Authent
// TODO: Stop sync ?
// fun switchToSession(sessionParams: SessionParams) {
// val newActiveSession = authenticator.getSession(sessionParams)
// val newActiveSession = authenticationService.getSession(sessionParams)
// activeSession.set(newActiveSession)
// }
}

View file

@ -21,8 +21,7 @@ import android.content.res.Resources
import dagger.BindsInstance
import dagger.Component
import im.vector.matrix.android.api.Matrix
import im.vector.matrix.android.api.auth.Authenticator
import im.vector.matrix.android.api.auth.registration.RegistrationService
import im.vector.matrix.android.api.auth.AuthenticationService
import im.vector.matrix.android.api.session.Session
import im.vector.riotx.ActiveSessionDataSource
import im.vector.riotx.EmojiCompatFontProvider
@ -101,9 +100,7 @@ interface VectorComponent {
fun incomingKeyRequestHandler(): KeyRequestHandler
fun authenticator(): Authenticator
fun registrationService(): RegistrationService
fun authenticationService(): AuthenticationService
fun bugReporter(): BugReporter

View file

@ -24,8 +24,7 @@ import dagger.Binds
import dagger.Module
import dagger.Provides
import im.vector.matrix.android.api.Matrix
import im.vector.matrix.android.api.auth.Authenticator
import im.vector.matrix.android.api.auth.registration.RegistrationService
import im.vector.matrix.android.api.auth.AuthenticationService
import im.vector.matrix.android.api.session.Session
import im.vector.riotx.features.navigation.DefaultNavigator
import im.vector.riotx.features.navigation.Navigator
@ -65,14 +64,8 @@ abstract class VectorModule {
@Provides
@JvmStatic
fun providesAuthenticator(matrix: Matrix): Authenticator {
return matrix.authenticator()
}
@Provides
@JvmStatic
fun providesRegistrationService(matrix: Matrix): RegistrationService {
return matrix.registrationService()
fun providesAuthenticationService(matrix: Matrix): AuthenticationService {
return matrix.authenticationService()
}
}

View file

@ -21,9 +21,7 @@ import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AlertDialog
import com.bumptech.glide.Glide
import im.vector.matrix.android.api.Matrix
import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.api.auth.Authenticator
import im.vector.riotx.R
import im.vector.riotx.core.di.ActiveSessionHolder
import im.vector.riotx.core.di.ScreenComponent
@ -56,8 +54,6 @@ class MainActivity : VectorBaseActivity() {
}
}
@Inject lateinit var matrix: Matrix
@Inject lateinit var authenticator: Authenticator
@Inject lateinit var sessionHolder: ActiveSessionHolder
@Inject lateinit var errorFormatter: ErrorFormatter

View file

@ -21,12 +21,11 @@ import com.airbnb.mvrx.*
import com.squareup.inject.assisted.Assisted
import com.squareup.inject.assisted.AssistedInject
import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.api.auth.AuthenticationWizard
import im.vector.matrix.android.api.auth.Authenticator
import im.vector.matrix.android.api.auth.login.LoginWizard
import im.vector.matrix.android.api.auth.AuthenticationService
import im.vector.matrix.android.api.auth.data.HomeServerConnectionConfig
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.RegistrationService
import im.vector.matrix.android.api.auth.registration.RegistrationWizard
import im.vector.matrix.android.api.session.Session
import im.vector.matrix.android.api.util.Cancelable
@ -47,8 +46,7 @@ import java.util.concurrent.CancellationException
*
*/
class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginViewState,
private val authenticator: Authenticator,
private val registrationService: RegistrationService,
private val authenticationService: AuthenticationService,
private val activeSessionHolder: ActiveSessionHolder,
private val pushRuleTriggerListener: PushRuleTriggerListener,
private val sessionListener: SessionListener)
@ -75,7 +73,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
private set
private var registrationWizard: RegistrationWizard? = null
private var authenticationWizard: AuthenticationWizard? = null
private var loginWizard: LoginWizard? = null
var serverType: ServerType = ServerType.MatrixOrg
private set
@ -310,9 +308,9 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
}
private fun handleResetPassword(action: LoginAction.ResetPassword) {
val safeAuthenticationWizard = authenticationWizard
val safeLoginWizard = loginWizard
if (safeAuthenticationWizard == null) {
if (safeLoginWizard == null) {
setState {
copy(
asyncResetPassword = Fail(Throwable("Bad configuration"))
@ -327,7 +325,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
)
}
currentTask = safeAuthenticationWizard.resetPassword(action.email, action.newPassword, object : MatrixCallback<Unit> {
currentTask = safeLoginWizard.resetPassword(action.email, action.newPassword, object : MatrixCallback<Unit> {
override fun onSuccess(data: Unit) {
setState {
copy(
@ -349,9 +347,9 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
}
private fun handleResetPasswordMailConfirmed() {
val safeAuthenticationWizard = authenticationWizard
val safeLoginWizard = loginWizard
if (safeAuthenticationWizard == null) {
if (safeLoginWizard == null) {
setState {
copy(
asyncResetMailConfirmed = Fail(Throwable("Bad configuration"))
@ -364,7 +362,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
)
}
currentTask = safeAuthenticationWizard.resetPasswordMailConfirmed(object : MatrixCallback<Unit> {
currentTask = safeLoginWizard.resetPasswordMailConfirmed(object : MatrixCallback<Unit> {
override fun onSuccess(data: Unit) {
setState {
copy(
@ -386,9 +384,9 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
}
private fun handleLogin(action: LoginAction.Login) {
val safeAuthenticationWizard = authenticationWizard
val safeLoginWizard = loginWizard
if (safeAuthenticationWizard == null) {
if (safeLoginWizard == null) {
setState {
copy(
asyncLoginAction = Fail(Throwable("Bad configuration"))
@ -401,7 +399,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
)
}
currentTask = safeAuthenticationWizard.authenticate(
currentTask = safeLoginWizard.login(
action.login,
action.password,
action.initialDeviceName,
@ -440,7 +438,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
)
}
registrationWizard = registrationService.getOrCreateRegistrationWizard(homeServerConnectionConfigFinal)
registrationWizard = authenticationService.getOrCreateRegistrationWizard(homeServerConnectionConfigFinal)
currentTask = registrationWizard?.getRegistrationFlow(registrationCallback)
}
@ -453,7 +451,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
// Notify the user
_viewEvents.post(LoginViewEvents.RegistrationError(Throwable("Bad configuration")))
} else {
authenticationWizard = authenticator.createAuthenticationWizard(homeServerConnectionConfigFinal)
loginWizard = authenticationService.createLoginWizard(homeServerConnectionConfigFinal)
}
}
@ -479,7 +477,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
// Should not happen
Timber.w("homeServerConnectionConfig is null")
} else {
authenticator.createSessionFromSso(homeServerConnectionConfigFinal, action.credentials, object : MatrixCallback<Session> {
authenticationService.createSessionFromSso(homeServerConnectionConfigFinal, action.credentials, object : MatrixCallback<Session> {
override fun onSuccess(data: Session) {
onSessionCreated(data)
}
@ -507,7 +505,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
currentTask?.cancel()
currentTask = null
homeServerConnectionConfig = newConfig
authenticationWizard = null
loginWizard = null
registrationWizard = null
val homeServerConnectionConfigFinal = homeServerConnectionConfig
@ -526,7 +524,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
)
}
currentTask = authenticator.getLoginFlow(homeServerConnectionConfigFinal, object : MatrixCallback<LoginFlowResponse> {
currentTask = authenticationService.getLoginFlow(homeServerConnectionConfigFinal, object : MatrixCallback<LoginFlowResponse> {
override fun onFailure(failure: Throwable) {
setState {
copy(