mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
Login screens: reset SDK when home server url is deleted
This commit is contained in:
parent
aa51764068
commit
fd90f3b9fc
3 changed files with 17 additions and 2 deletions
|
@ -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.
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue