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()
|
fun cancelPendingLoginOrRegistration()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset all pending settings, including current HomeServerConnectionConfig
|
||||||
|
*/
|
||||||
|
fun reset()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if there is an authenticated [Session].
|
* Check if there is an authenticated [Session].
|
||||||
* @return true if there is at least one active 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,
|
override fun createSessionFromSso(homeServerConnectionConfig: HomeServerConnectionConfig,
|
||||||
credentials: Credentials,
|
credentials: Credentials,
|
||||||
callback: MatrixCallback<Session>): Cancelable {
|
callback: MatrixCallback<Session>): Cancelable {
|
||||||
|
|
|
@ -240,7 +240,8 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
|
||||||
|
|
||||||
when (action) {
|
when (action) {
|
||||||
LoginAction.ResetLogin -> {
|
LoginAction.ResetLogin -> {
|
||||||
// TODO Clear wizard here?
|
authenticationService.cancelPendingLoginOrRegistration()
|
||||||
|
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
asyncLoginAction = Uninitialized,
|
asyncLoginAction = Uninitialized,
|
||||||
|
@ -249,7 +250,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LoginAction.ResetHomeServerUrl -> {
|
LoginAction.ResetHomeServerUrl -> {
|
||||||
authenticationService.cancelPendingLoginOrRegistration()
|
authenticationService.reset()
|
||||||
|
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
|
|
Loading…
Reference in a new issue