diff --git a/RiotSwiftUI/Modules/Authentication/Common/Service/MatrixSDK/SessionCreator.swift b/RiotSwiftUI/Modules/Authentication/Common/Service/MatrixSDK/SessionCreator.swift index 26bb85c4d..77add2d69 100644 --- a/RiotSwiftUI/Modules/Authentication/Common/Service/MatrixSDK/SessionCreator.swift +++ b/RiotSwiftUI/Modules/Authentication/Common/Service/MatrixSDK/SessionCreator.swift @@ -27,6 +27,13 @@ protocol SessionCreatorProtocol { /// A struct that provides common functionality to create a new session. struct SessionCreator: SessionCreatorProtocol { + + private let accountManager: MXKAccountManager + + init(withAccountManager accountManager: MXKAccountManager = .shared()) { + self.accountManager = accountManager + } + func createSession(credentials: MXCredentials, client: AuthenticationRestClient) -> MXSession { // Report the new account in account manager if credentials.identityServer == nil { @@ -39,7 +46,7 @@ struct SessionCreator: SessionCreatorProtocol { account.identityServerURL = identityServer } - MXKAccountManager.shared().addAccount(account, andOpenSession: true) + accountManager.addAccount(account, andOpenSession: true) return account.mxSession } }