mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 01:19:33 +00:00
Do not restore session with invalid token.
This commit is contained in:
committed by
Benoit Marty
parent
266f93cc28
commit
6be984efc8
+5
@@ -25,6 +25,11 @@ import kotlinx.coroutines.flow.StateFlow
|
|||||||
interface MatrixAuthenticationService {
|
interface MatrixAuthenticationService {
|
||||||
fun loggedInStateFlow(): Flow<LoggedInState>
|
fun loggedInStateFlow(): Flow<LoggedInState>
|
||||||
suspend fun getLatestSessionId(): SessionId?
|
suspend fun getLatestSessionId(): SessionId?
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restore a session from a [sessionId].
|
||||||
|
* Do not restore anything it the access token is not valid anymore.
|
||||||
|
*/
|
||||||
suspend fun restoreSession(sessionId: SessionId): Result<MatrixClient>
|
suspend fun restoreSession(sessionId: SessionId): Result<MatrixClient>
|
||||||
fun getHomeserverDetails(): StateFlow<MatrixHomeServerDetails?>
|
fun getHomeserverDetails(): StateFlow<MatrixHomeServerDetails?>
|
||||||
suspend fun setHomeserver(homeserver: String): Result<Unit>
|
suspend fun setHomeserver(homeserver: String): Result<Unit>
|
||||||
|
|||||||
+5
-1
@@ -76,7 +76,11 @@ class RustMatrixAuthenticationService @Inject constructor(
|
|||||||
runCatching {
|
runCatching {
|
||||||
val sessionData = sessionStore.getSession(sessionId.value)
|
val sessionData = sessionStore.getSession(sessionId.value)
|
||||||
if (sessionData != null) {
|
if (sessionData != null) {
|
||||||
rustMatrixClientFactory.create(sessionData)
|
if (sessionData.isTokenValid) {
|
||||||
|
rustMatrixClientFactory.create(sessionData)
|
||||||
|
} else {
|
||||||
|
error("Token is not valid")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
error("No session to restore with id $sessionId")
|
error("No session to restore with id $sessionId")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user