Skip to content

Commit

Permalink
TF-2464 Save keychain as data
Browse files Browse the repository at this point in the history
Signed-off-by: dab246 <[email protected]>
  • Loading branch information
dab246 authored and hoangdat committed Jan 20, 2024
1 parent 7f54c03 commit e29e93e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
12 changes: 6 additions & 6 deletions ios/TwakeMailNSE/Keychain/KeychainController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ class KeychainController: KeychainControllerDelegate {

func updateEmailDeliveryStateToKeychain(accountId: String, newEmailDeliveryState: String) {
do {
if let sharingSession = retrieveSharingSessionFromKeychain(accountId: accountId) {
let newSharingSession = sharingSession.updateEmailDeliveryState(newEmailDeliveryState: newEmailDeliveryState)
try keychain.set(newSharingSession.toJson() ?? "", key: accountId)
if let sharingSession = retrieveSharingSessionFromKeychain(accountId: accountId),
let newSharingSessionData = sharingSession.updateEmailDeliveryState(newEmailDeliveryState: newEmailDeliveryState).toData() {
try keychain.set(newSharingSessionData, key: accountId)
}
} catch {}
}

func updateTokenOidc(accountId: String, newTokenOidc: TokenOidc) {
do {
if let sharingSession = retrieveSharingSessionFromKeychain(accountId: accountId) {
let newSharingSession = sharingSession.updateTokenOidc(newTokenOidc: newTokenOidc)
try keychain.set(newSharingSession.toJson() ?? "", key: accountId)
if let sharingSession = retrieveSharingSessionFromKeychain(accountId: accountId),
let newSharingSessionData = sharingSession.updateTokenOidc(newTokenOidc: newTokenOidc).toData() {
try keychain.set(newSharingSessionData, key: accountId)
}
} catch {}
}
Expand Down
7 changes: 0 additions & 7 deletions ios/TwakeMailNSE/Model/KeychainSharingSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,4 @@ extension KeychainSharingSession {
}
return nil
}

func toJson() -> String? {
if let data = toData(), let jsonString = String(data: data, encoding: .utf8) {
return jsonString
}
return nil
}
}

0 comments on commit e29e93e

Please sign in to comment.