diff --git a/Data/Data/Model/AppUser.swift b/Data/Data/Model/AppUser.swift index 49210852..2b4bdf03 100644 --- a/Data/Data/Model/AppUser.swift +++ b/Data/Data/Model/AppUser.swift @@ -35,7 +35,7 @@ public struct AppUser: Identifiable, Codable, Hashable { } public init(id: String, firstName: String?, lastName: String?, emailId: String?, - phoneNumber: String?, imageUrl: String? = nil, deviceFcmToken: String? = nil, + phoneNumber: String? = nil, imageUrl: String? = nil, deviceFcmToken: String? = nil, loginType: LoginType, totalOweAmount: Double = 0, isActive: Bool = true) { self.id = id self.firstName = firstName diff --git a/Splito/UI/Login/EmailLogin/EmailLoginViewModel.swift b/Splito/UI/Login/EmailLogin/EmailLoginViewModel.swift index 5a4cbf75..fd83859c 100644 --- a/Splito/UI/Login/EmailLogin/EmailLoginViewModel.swift +++ b/Splito/UI/Login/EmailLogin/EmailLoginViewModel.swift @@ -53,15 +53,14 @@ public class EmailLoginViewModel: BaseViewModel, ObservableObject { showAlertFor(title: "Email Already in Use", message: "The email address is already associated with an existing account. Please use a different email or log in to your existing account.") 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) - } } else { - isLoginInProgress = false LogE("EmailLoginViewModel: \(#function) No user found with this email.") } + + FirebaseAuth.Auth.auth().signIn(withEmail: email, password: password) { [weak self] result, error in + self?.isLoginInProgress = false + self?.handleAuthResponse(result: result, error: error, isLogin: true) + } } catch { isLoginInProgress = false LogE("EmailLoginViewModel: \(#function) Error fetching user: \(error).") @@ -75,7 +74,7 @@ public class EmailLoginViewModel: BaseViewModel, ObservableObject { handleFirebaseAuthErrors(error) } else if let result { let user = AppUser(id: result.user.uid, firstName: "", lastName: "", - emailId: email, phoneNumber: nil, loginType: .Email) + emailId: email, loginType: .Email) Task { await storeUser(user: user) }