File tree Expand file tree Collapse file tree
FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -221,9 +221,7 @@ public final class AuthService {
221221 throw AuthServiceError . noCurrentUser
222222 }
223223
224- try await withReauthenticationIfNeeded ( on: user) {
225- try await user. link ( with: credentials)
226- }
224+ try await user. link ( with: credentials)
227225 updateAuthenticationState ( )
228226 } catch {
229227 // Possible conflicts from user.link():
Original file line number Diff line number Diff line change @@ -35,10 +35,12 @@ struct AccountConflictModifier: ViewModifier {
3535 @Environment ( \. mfaHandler) private var mfaHandler
3636 @Environment ( \. reportError) private var reportError
3737 @State private var pendingCredentialForLinking : AuthCredential ?
38+ @State private var reauthCoordinator = ReauthenticationCoordinator ( )
3839
3940 func body( content: Content ) -> some View {
4041 content
4142 . environment ( \. accountConflictHandler, handleAccountConflict)
43+ . withReauthentication ( coordinator: reauthCoordinator)
4244 . onChange ( of: authService. authenticationState) { _, newState in
4345 // Auto-link pending credential after successful sign-in
4446 if newState == . authenticated {
@@ -82,7 +84,12 @@ struct AccountConflictModifier: ViewModifier {
8284
8385 Task {
8486 do {
85- try await authService. linkAccounts ( credentials: credential)
87+ try await withReauthenticationIfNeeded (
88+ authService: authService,
89+ coordinator: reauthCoordinator
90+ ) {
91+ try await authService. linkAccounts ( credentials: credential)
92+ }
8693 // Successfully linked, clear the pending credential
8794 pendingCredentialForLinking = nil
8895 } catch {
You can’t perform that action at this time.
0 commit comments