@@ -59,8 +59,6 @@ public enum SignInOutcome: @unchecked Sendable {
59
59
case signedIn( AuthDataResult ? )
60
60
}
61
61
62
-
63
-
64
62
@MainActor
65
63
private final class AuthListenerManager {
66
64
private var authStateHandle : AuthStateDidChangeListenerHandle ?
@@ -236,6 +234,7 @@ public final class AuthService {
236
234
}
237
235
do {
238
236
let result = try await currentUser? . link ( with: credentials)
237
+ signedInCredential = credentials
239
238
updateAuthenticationState ( )
240
239
return . signedIn( result)
241
240
} catch let error as NSError {
@@ -263,11 +262,18 @@ public final class AuthService {
263
262
updateAuthenticationState ( )
264
263
return . signedIn( result)
265
264
}
266
- } catch {
265
+ } catch let error as NSError {
267
266
authenticationState = . unauthenticated
268
- errorMessage = string. localizedErrorMessage (
269
- for: error
270
- )
267
+ errorMessage = string. localizedErrorMessage ( for: error)
268
+
269
+ // Check if this is an MFA required error
270
+ if error. code == AuthErrorCode . secondFactorRequired. rawValue {
271
+ if let resolver = error
272
+ . userInfo [ AuthErrorUserInfoMultiFactorResolverKey] as? MultiFactorResolver {
273
+ return handleMFARequiredError ( resolver: resolver)
274
+ }
275
+ }
276
+
271
277
throw error
272
278
}
273
279
}
@@ -527,7 +533,7 @@ public extension AuthService {
527
533
}
528
534
}
529
535
530
- // MARK: - MFA Methods (Placeholder implementations)
536
+ // MARK: - MFA Methods
531
537
532
538
public extension AuthService {
533
539
func startMfaEnrollment( type: SecondFactorType , accountName: String ? = nil ,
0 commit comments