Login screens: reset SDK when home server url is deleted

This commit is contained in:
Benoit Marty 2019-11-27 15:08:36 +01:00
parent aa51764068
commit fd90f3b9fc
3 changed files with 17 additions and 2 deletions

View file

@ -52,6 +52,11 @@ interface AuthenticationService {
*/
fun cancelPendingLoginOrRegistration()
/**
* Reset all pending settings, including current HomeServerConnectionConfig
*/
fun reset()
/**
* Check if there is an authenticated [Session].
* @return true if there is at least one active session.

View file

@ -166,6 +166,15 @@ internal class DefaultAuthenticationService @Inject constructor(@Unauthenticated
}
}
override fun reset() {
currentLoginWizard = null
currentRegistrationWizard = null
GlobalScope.launch(coroutineDispatchers.main) {
pendingSessionStore.delete()
}
}
override fun createSessionFromSso(homeServerConnectionConfig: HomeServerConnectionConfig,
credentials: Credentials,
callback: MatrixCallback<Session>): Cancelable {

View file

@ -240,7 +240,8 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
when (action) {
LoginAction.ResetLogin -> {
// TODO Clear wizard here?
authenticationService.cancelPendingLoginOrRegistration()
setState {
copy(
asyncLoginAction = Uninitialized,
@ -249,7 +250,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
}
}
LoginAction.ResetHomeServerUrl -> {
authenticationService.cancelPendingLoginOrRegistration()
authenticationService.reset()
setState {
copy(