TF-2464 Save keychain as data
Signed-off-by: dab246 <tdvu@linagora.com> (cherry picked from commit e29e93e97d35d21dc095688a40f074572488486a)
This commit is contained in:
@@ -42,18 +42,18 @@ class KeychainController: KeychainControllerDelegate {
|
|||||||
|
|
||||||
func updateEmailDeliveryStateToKeychain(accountId: String, newEmailDeliveryState: String) {
|
func updateEmailDeliveryStateToKeychain(accountId: String, newEmailDeliveryState: String) {
|
||||||
do {
|
do {
|
||||||
if let sharingSession = retrieveSharingSessionFromKeychain(accountId: accountId) {
|
if let sharingSession = retrieveSharingSessionFromKeychain(accountId: accountId),
|
||||||
let newSharingSession = sharingSession.updateEmailDeliveryState(newEmailDeliveryState: newEmailDeliveryState)
|
let newSharingSessionData = sharingSession.updateEmailDeliveryState(newEmailDeliveryState: newEmailDeliveryState).toData() {
|
||||||
try keychain.set(newSharingSession.toJson() ?? "", key: accountId)
|
try keychain.set(newSharingSessionData, key: accountId)
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateTokenOidc(accountId: String, newTokenOidc: TokenOidc) {
|
func updateTokenOidc(accountId: String, newTokenOidc: TokenOidc) {
|
||||||
do {
|
do {
|
||||||
if let sharingSession = retrieveSharingSessionFromKeychain(accountId: accountId) {
|
if let sharingSession = retrieveSharingSessionFromKeychain(accountId: accountId),
|
||||||
let newSharingSession = sharingSession.updateTokenOidc(newTokenOidc: newTokenOidc)
|
let newSharingSessionData = sharingSession.updateTokenOidc(newTokenOidc: newTokenOidc).toData() {
|
||||||
try keychain.set(newSharingSession.toJson() ?? "", key: accountId)
|
try keychain.set(newSharingSessionData, key: accountId)
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,11 +55,4 @@ extension KeychainSharingSession {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func toJson() -> String? {
|
|
||||||
if let data = toData(), let jsonString = String(data: data, encoding: .utf8) {
|
|
||||||
return jsonString
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user