This commit is contained in:
Trey t
2023-07-05 22:08:47 -05:00
parent 4bcfd6a7fa
commit e43e5b11bf
8 changed files with 207 additions and 28 deletions

View File

@@ -8,6 +8,9 @@
import Foundation
class UserStore: ObservableObject {
static let userNameKeychainValue = "username"
static let passwordKeychainValue = "password"
static let userDefaultsRegisteredUserKey = "registeredUserKey"
static let shared = UserStore()
@@ -34,6 +37,13 @@ class UserStore: ObservableObject {
LoginFetchable(postData: postData).fetch(completion: { result in
switch result {
case .success(let model):
if let email = postData["email"] as? String,
let password = postData["password"] as? String,
let data = password.data(using: .utf8) {
try? KeychainInterface.save(password: data,
account: email)
}
DispatchQueue.main.async {
self.registeredUser = model
let data = try! JSONEncoder().encode(model)