Storage location change (#404)

* Remove LegacyRestorationToken and handling
* Fixes #389 - Migrate and store session data in Application Support instead of Caches
This commit is contained in:
Stefan Ceriu
2023-01-06 10:27:27 +02:00
committed by GitHub
parent e573bc0dd2
commit 34eb835a0b
4 changed files with 30 additions and 43 deletions
@@ -50,17 +50,6 @@ class KeychainController: KeychainControllerProtocol {
return nil
}
// Handle the previous restoration token format as we don't want users to have to log in again
// It will automatically be updated to the new version after login
if let legacyRestorationToken = try? JSONDecoder().decode(LegacyRestorationToken.self, from: tokenData) {
return .init(session: .init(accessToken: legacyRestorationToken.session.accessToken,
refreshToken: nil,
userId: legacyRestorationToken.session.userId,
deviceId: legacyRestorationToken.session.deviceId,
homeserverUrl: legacyRestorationToken.homeURL,
isSoftLogout: legacyRestorationToken.isSoftLogout ?? false))
}
return try JSONDecoder().decode(RestorationToken.self, from: tokenData)
} catch {
MXLog.error("Failed retrieving user restore token")
@@ -46,31 +46,3 @@ extension MatrixRustSDK.Session: Codable {
case accessToken, refreshToken, userId, deviceId, homeserverUrl, isSoftLogout
}
}
#warning("Remove this in a couple of releases - sceriu 03.11.2022")
struct LegacyRestorationToken: Decodable {
let isGuest: Bool?
let isSoftLogout: Bool?
let homeURL: String
let session: Session
enum CodingKeys: String, CodingKey {
case isGuest = "is_guest"
case isSoftLogout = "is_soft_logout"
case homeURL = "homeurl"
case session
}
struct Session: Decodable {
let accessToken: String
let userId: String
let deviceId: String
// swiftlint:disable:next nesting
enum CodingKeys: String, CodingKey {
case accessToken = "access_token"
case userId = "user_id"
case deviceId = "device_id"
}
}
}