Skip to content

Commit 82a82b0

Browse files
error message should be on local state
1 parent 28fb71a commit 82a82b0

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/FirebaseAuthSwiftUI/Services/AuthEnvironment.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public final class AuthEnvironment {
6363
}
6464

6565
public var currentUser: User?
66-
public var errorMessage = ""
6766
public var authenticationState: AuthenticationState = .unauthenticated
6867
public var authenticationFlow: AuthenticationFlow = .login
6968

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/FirebaseAuthSwiftUI/Views/EmailPasswordView.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public struct EmailPasswordView {
2222
@State private var email = ""
2323
@State private var password = ""
2424
@State private var confirmPassword = ""
25+
@State private var errorMessage = ""
2526

2627
@FocusState private var focus: FocusableField?
2728

@@ -42,7 +43,7 @@ public struct EmailPasswordView {
4243
try await provider.signIn(withEmail: email, password: password)
4344
dismiss()
4445
} catch {
45-
authEnvironment.errorMessage = error.localizedDescription
46+
errorMessage = error.localizedDescription
4647
}
4748
}
4849

@@ -51,7 +52,7 @@ public struct EmailPasswordView {
5152
try await provider.createUser(withEmail: email, password: password)
5253
dismiss()
5354
} catch {
54-
authEnvironment.errorMessage = error.localizedDescription
55+
errorMessage = error.localizedDescription
5556
}
5657
}
5758
}
@@ -90,7 +91,7 @@ extension EmailPasswordView: View {
9091
.padding(.bottom, 8)
9192

9293
if authEnvironment.authenticationFlow == .login {
93-
NavigationLink(destination: PasswordRecoveryView()
94+
NavigationLink(destination: PasswordRecoveryView(provider: provider)
9495
.environment(authEnvironment)) {
9596
Text("Forgotten Password?")
9697
}
@@ -133,6 +134,7 @@ extension EmailPasswordView: View {
133134
.padding([.top, .bottom], 8)
134135
.frame(maxWidth: .infinity)
135136
.buttonStyle(.borderedProminent)
137+
Text(errorMessage).foregroundColor(.red)
136138
}
137139
}
138140
}

0 commit comments

Comments
 (0)