mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Make sure we don't reuse an old NSEUserSession after logging out and back in. (#3273)
This commit is contained in:
parent
022cc59d56
commit
d24214c674
@ -72,7 +72,9 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
|
||||
MXLog.info("\(tag) Payload came: \(request.content.userInfo)")
|
||||
|
||||
Self.serialQueue.sync {
|
||||
if Self.userSession == nil {
|
||||
// If the session directories have changed, the user has logged out and back in (even if they entered the same user ID).
|
||||
// We can't do this comparison with the access token of the existing session here due to token refresh when using OIDC.
|
||||
if Self.userSession == nil || Self.userSession?.sessionDirectories != credentials.restorationToken.sessionDirectories {
|
||||
// This function might be run concurrently and from different processes
|
||||
// It's imperative that we create **at most** one UserSession/Client per process
|
||||
Task.synchronous { [appHooks] in
|
||||
|
@ -9,6 +9,8 @@ import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
final class NSEUserSession {
|
||||
let sessionDirectories: SessionDirectories
|
||||
|
||||
private let baseClient: Client
|
||||
private let notificationClient: NotificationClient
|
||||
private let userID: String
|
||||
@ -18,6 +20,8 @@ final class NSEUserSession {
|
||||
private let delegateHandle: TaskHandle?
|
||||
|
||||
init(credentials: KeychainCredentials, clientSessionDelegate: ClientSessionDelegate, appHooks: AppHooks) async throws {
|
||||
sessionDirectories = credentials.restorationToken.sessionDirectories
|
||||
|
||||
userID = credentials.userID
|
||||
if credentials.restorationToken.passphrase != nil {
|
||||
MXLog.info("Restoring client with encrypted store.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user