mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Fix #1947 - Check expected files are still present before restoring a session.
This commit is contained in:
committed by
Stefan Ceriu
parent
f7aeb3ee95
commit
3a600a94d5
@@ -51,6 +51,14 @@ struct SessionDirectories: Hashable, Codable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check that mission critical files (the crypto db) are still in the right place when restoring a session
|
||||||
|
/// iOS might decide to move the app with its user defaults and keychain but without
|
||||||
|
/// some of the files stored in the shared container e.g. after a device transfer, offloading etc.
|
||||||
|
/// If that happens we should fail the session restoration.
|
||||||
|
func isNonTransientUserDataValid() -> Bool {
|
||||||
|
FileManager.default.fileExists(atPath: dataPath.appending("/matrix-sdk-crypto.sqlite3"))
|
||||||
|
}
|
||||||
|
|
||||||
private func deleteFiles(at url: URL, with prefix: String) throws {
|
private func deleteFiles(at url: URL, with prefix: String) throws {
|
||||||
let sessionDirectoryContents = try FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys: nil)
|
let sessionDirectoryContents = try FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys: nil)
|
||||||
for url in sessionDirectoryContents where url.lastPathComponent.hasPrefix(prefix) {
|
for url in sessionDirectoryContents where url.lastPathComponent.hasPrefix(prefix) {
|
||||||
|
|||||||
@@ -118,6 +118,11 @@ class UserSessionStore: UserSessionStoreProtocol {
|
|||||||
MXLog.info("Restoring client with encrypted store.")
|
MXLog.info("Restoring client with encrypted store.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guard credentials.restorationToken.sessionDirectories.isNonTransientUserDataValid() else {
|
||||||
|
MXLog.error("Failed restoring login, missing non-transient user data")
|
||||||
|
return .failure(.failedRestoringLogin)
|
||||||
|
}
|
||||||
|
|
||||||
let homeserverURL = credentials.restorationToken.session.homeserverUrl
|
let homeserverURL = credentials.restorationToken.session.homeserverUrl
|
||||||
|
|
||||||
let builder = ClientBuilder
|
let builder = ClientBuilder
|
||||||
|
|||||||
Reference in New Issue
Block a user