From 3a2522a342862141802f7aba38f12f7f3d9f62a6 Mon Sep 17 00:00:00 2001 From: NiraliSonani Date: Mon, 16 Dec 2024 13:04:33 +0530 Subject: [PATCH] Remove unwanted code --- Data/Data/Store/UserStore.swift | 28 +------------------ .../EmailLogin/EmailLoginViewModel.swift | 6 ++-- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/Data/Data/Store/UserStore.swift b/Data/Data/Store/UserStore.swift index 2cc695c48..813517508 100644 --- a/Data/Data/Store/UserStore.swift +++ b/Data/Data/Store/UserStore.swift @@ -6,7 +6,6 @@ // import FirebaseFirestore -import FirebaseAuth class UserStore: ObservableObject { @@ -48,7 +47,7 @@ class UserStore: ObservableObject { func fetchUserBy(email: String) async throws -> AppUser? { let snapshot = try await usersCollection.whereField("email_id", isEqualTo: email).getDocuments() - + if let document = snapshot.documents.first { let fetchedUser = try document.data(as: AppUser.self) LogD("UserStore: \(#function) User fetched successfully by email.") @@ -88,29 +87,4 @@ class UserStore: ObservableObject { func deactivateUserAfterDelete(userId: String) async throws { try await usersCollection.document(userId).updateData(["is_active": false]) } - - func deleteAccount() { - // Get the currently signed-in user - guard let user = Auth.auth().currentUser else { - print("No user is currently signed in.") - return - } - - // Delete the user's account - user.delete { error in - if let error { - // Handle error (e.g., user may need to reauthenticate) - print("Error deleting account: \(error.localizedDescription)") - - // Example: Reauthentication may be required - if let authError = error as? NSError, - authError.code == AuthErrorCode.requiresRecentLogin.rawValue { - print("User needs to reauthenticate before deleting their account.") - // Call a reauthentication flow here - } - } else { - print("User account deleted successfully.") - } - } - } } diff --git a/Splito/UI/Login/EmailLogin/EmailLoginViewModel.swift b/Splito/UI/Login/EmailLogin/EmailLoginViewModel.swift index ceda93ac0..6a2c07f3c 100644 --- a/Splito/UI/Login/EmailLogin/EmailLoginViewModel.swift +++ b/Splito/UI/Login/EmailLogin/EmailLoginViewModel.swift @@ -42,18 +42,18 @@ public class EmailLoginViewModel: BaseViewModel, ObservableObject { func onLoginClick() { guard validateEmailAndPassword() else { return } - + Task { do { isLoginInProgress = true - + if let user = try await userRepository.fetchUserBy(email: email) { if user.loginType != .Email { isLoginInProgress = false showAlertFor(title: "Error", message: "This account already exists with a different login method.") return } - + FirebaseAuth.Auth.auth().signIn(withEmail: email, password: password) { [weak self] result, error in self?.isLoginInProgress = false self?.handleAuthResponse(result: result, error: error, isLogin: true)