Skip to content

Commit

Permalink
When user not found then not getting error
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-nirali-s committed Dec 17, 2024
1 parent abe4bc4 commit 0903ef1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Data/Data/Model/AppUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions Splito/UI/Login/EmailLogin/EmailLoginViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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).")
Expand All @@ -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)
}
Expand Down

0 comments on commit 0903ef1

Please sign in to comment.