You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: FirebaseSwiftUI/README.md
+41-6Lines changed: 41 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -278,6 +278,8 @@ When a sensitive operation requires reauthentication, the default views automati
278
278
279
279
-**Email/Password**: Present a sheet prompting the user to enter their password before continuing.
280
280
281
+
-**Email Link**: Show an alert asking to send a verification email, then present a sheet with instructions to check email. The user taps the link in their email to complete reauthentication.
282
+
281
283
-**Phone**: Show an alert explaining verification is needed, then present a sheet for SMS code verification.
282
284
283
285
The operation automatically retries after successful reauthentication. No additional code is required when using `AuthPickerView` or the built-in account management views (`UpdatePasswordView`, `SignedInView`, etc.).
@@ -655,7 +657,7 @@ When building custom views, you need to handle several things yourself that `Aut
655
657
656
658
### Reauthentication in Custom Views
657
659
658
-
When building custom views, handle reauthentication by catching specific errors and implementing your own flow. Sensitive operations throw three types of reauthentication errors, each containing context information.
660
+
When building custom views, handle reauthentication by catching specific errors and implementing your own flow. Sensitive operations throw four types of reauthentication errors, each containing context information.
659
661
660
662
#### Implementation Patterns
661
663
@@ -720,6 +722,31 @@ do {
720
722
}
721
723
```
722
724
725
+
**Email Link:**
726
+
727
+
Catch the error, send verification email, and handle the incoming URL:
Sends a sign-in link to the specified email address.
1226
+
Sends a sign-in link to the specified email address. Can also be used for reauthentication.
1200
1227
1201
1228
**Parameters:**
1202
1229
-`email`: Email address to send the link to
1230
+
-`isReauth`: Whether this is for reauthentication (default: `false`)
1203
1231
1204
1232
**Throws:**`AuthServiceError` or Firebase Auth errors
1205
1233
1206
1234
**Requirements:**`emailLinkSignInActionCodeSettings` must be configured in `AuthConfiguration`
1207
1235
1236
+
**Note:** When `isReauth` is `true`, the method stores the email for reauthentication flow. The same `handleSignInLink(url:)` method handles both sign-in and reauthentication automatically.
1237
+
1208
1238
---
1209
1239
1210
1240
##### Handle Sign-In Link
@@ -1213,13 +1243,15 @@ Sends a sign-in link to the specified email address.
Handles the sign-in flow when the user taps the email link.
1246
+
Handles the email link flow when the user taps the link. Automatically routes to either sign-in or reauthentication based on the current context.
1217
1247
1218
1248
**Parameters:**
1219
1249
-`url`: The deep link URL from the email
1220
1250
1221
1251
**Throws:**`AuthServiceError` or Firebase Auth errors
1222
1252
1253
+
**Note:** This method handles both initial sign-in and reauthentication flows automatically. The behavior is determined by whether `sendEmailSignInLink(email:isReauth:)` was called with `isReauth: true`.
1254
+
1223
1255
---
1224
1256
1225
1257
#### Phone Authentication
@@ -1305,7 +1337,7 @@ Updates the current user's password. This is a sensitive operation that may requ
1305
1337
1306
1338
**Throws:**
1307
1339
-`AuthServiceError.noCurrentUser` if no user is signed in
1308
-
- Reauthentication errors (`emailReauthenticationRequired`, `phoneReauthenticationRequired`, or `oauthReauthenticationRequired`) if recent authentication is required - see [Reauthentication](#reauthentication-in-default-views)
1340
+
- Reauthentication errors (`emailReauthenticationRequired`, `emailLinkReauthenticationRequired`, `phoneReauthenticationRequired`, or `oauthReauthenticationRequired`) if recent authentication is required - see [Reauthentication](#reauthentication-in-default-views)
1309
1341
- Firebase Auth errors
1310
1342
1311
1343
---
@@ -1332,7 +1364,7 @@ Deletes the current user's account. This is a sensitive operation that requires
1332
1364
1333
1365
**Throws:**
1334
1366
-`AuthServiceError.noCurrentUser` if no user is signed in
1335
-
- Reauthentication errors (`emailReauthenticationRequired`, `phoneReauthenticationRequired`, or `oauthReauthenticationRequired`) if recent authentication is required - see [Reauthentication](#reauthentication-in-default-views)
1367
+
- Reauthentication errors (`emailReauthenticationRequired`, `emailLinkReauthenticationRequired`, `phoneReauthenticationRequired`, or `oauthReauthenticationRequired`) if recent authentication is required - see [Reauthentication](#reauthentication-in-default-views)
1336
1368
- Firebase Auth errors
1337
1369
1338
1370
---
@@ -1638,6 +1670,7 @@ public enum AuthServiceError: Error {
@@ -1653,6 +1686,8 @@ Thrown by sensitive operations when Firebase requires recent authentication. Eac
1653
1686
1654
1687
-**`emailReauthenticationRequired(context: EmailReauthContext)`**: Email/password provider. Context contains `email` and `displayMessage`. Prompt for password, then call `reauthenticate(with:)`.
1655
1688
1689
+
-**`emailLinkReauthenticationRequired(context: EmailLinkReauthContext)`**: Email link (passwordless) provider. Context contains `email` and `displayMessage`. Send verification email with `sendEmailSignInLink(email:isReauth:true)`, then handle the incoming link with `handleSignInLink(url:)`.
1690
+
1656
1691
-**`phoneReauthenticationRequired(context: PhoneReauthContext)`**: Phone provider. Context contains `phoneNumber` and `displayMessage`. Handle SMS verification, then call `reauthenticate(with:)`.
0 commit comments