File tree Expand file tree Collapse file tree 3 files changed +13
-10
lines changed
FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ public struct AccountMergeConflictContext: LocalizedError {
13
13
}
14
14
15
15
public enum AuthServiceError : LocalizedError {
16
- case invalidEmailLink
16
+ case invalidEmailLink( String )
17
17
case notConfiguredProvider( String )
18
18
case clientIdNotFound( String )
19
19
case notConfiguredActionCodeSettings( String )
@@ -24,8 +24,8 @@ public enum AuthServiceError: LocalizedError {
24
24
25
25
public var errorDescription : String ? {
26
26
switch self {
27
- case . invalidEmailLink:
28
- return " Invalid sign in link. Most likely, the link you used has expired. Try signing in again. "
27
+ case let . invalidEmailLink( description ) :
28
+ return description
29
29
case let . notConfiguredProvider( description) :
30
30
return description
31
31
case let . clientIdNotFound( description) :
Original file line number Diff line number Diff line change @@ -302,12 +302,20 @@ public extension AuthService {
302
302
func handleSignInLink( url url: URL ) async throws {
303
303
do {
304
304
guard let email = emailLink else {
305
- throw AuthServiceError . invalidEmailLink
305
+ throw AuthServiceError . invalidEmailLink ( " email address is missing from local storage " )
306
306
}
307
307
let link = url. absoluteString
308
+ guard let continueUrl = CommonUtils . getQueryParamValue ( from: link, paramName: " continueUrl " )
309
+ else {
310
+ throw AuthServiceError
311
+ . invalidEmailLink ( " `continueUrl` parameter is missing from the email link URL " )
312
+ }
308
313
309
314
if auth. isSignIn ( withEmailLink: link) {
310
- let anonymousUserID = CommonUtils . getAnonymousUserIdFromUrl ( from: link)
315
+ let anonymousUserID = CommonUtils . getQueryParamValue (
316
+ from: continueUrl,
317
+ paramName: " ui_auid "
318
+ )
311
319
if shouldHandleAnonymousUpgrade, anonymousUserID == currentUser? . uid {
312
320
let credential = EmailAuthProvider . credential ( withEmail: email, link: link)
313
321
try await handleAutoUpgradeAnonymousUser ( credentials: credential)
Original file line number Diff line number Diff line change @@ -54,9 +54,4 @@ public class CommonUtils {
54
54
55
55
return urlComponents. queryItems? . first ( where: { $0. name == paramName } ) ? . value
56
56
}
57
-
58
- public static func getAnonymousUserIdFromUrl( from urlString: String ) -> String ? {
59
- getQueryParamValue ( from: urlString, paramName: " continueUrl " )
60
- . flatMap { getQueryParamValue ( from: $0, paramName: " ui_auid " ) }
61
- }
62
57
}
You can’t perform that action at this time.
0 commit comments