From e9a7e8b33b9b5a774ba67af9dd0a0f452677125f Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Tue, 20 Dec 2022 03:33:03 +0100 Subject: [PATCH] Fixed the "logUserOut()" function in the ProfileView view for the Profile module to actually remove the account from the keychain storage. --- .../Sources/Profile/UI/Views/ProfileView.swift | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Modules/Sources/Profile/UI/Views/ProfileView.swift b/Modules/Sources/Profile/UI/Views/ProfileView.swift index 9e3b7fd..d72fe28 100644 --- a/Modules/Sources/Profile/UI/Views/ProfileView.swift +++ b/Modules/Sources/Profile/UI/Views/ProfileView.swift @@ -7,6 +7,7 @@ // import DataModels +import KeychainStorage import SwiftUI public struct ProfileView: View { @@ -15,6 +16,10 @@ public struct ProfileView: View { @Environment(\.dismiss) private var dismiss + // MARK: Storages + + @KeychainStorage(key: .KeychainStorage.account) var account: Account? + // MARK: Properties private let user: User? @@ -84,7 +89,7 @@ public struct ProfileView: View { Section { Button { - logout() + Task { await logUserOut() } } label: { Text( "profile.button.log_out.text", @@ -107,6 +112,16 @@ public struct ProfileView: View { } +// MARK: - Helpers + +private extension ProfileView { + func logUserOut() async { + account = nil + + logout() + } +} + // MARK: - Images+Constants private extension Image {