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 @@ -13,7 +13,7 @@ public struct AccountMergeConflictContext: LocalizedError {
1313}
1414
1515public enum AuthServiceError : LocalizedError {
16- case invalidEmailLink
16+ case invalidEmailLink( String )
1717 case notConfiguredProvider( String )
1818 case clientIdNotFound( String )
1919 case notConfiguredActionCodeSettings( String )
@@ -24,8 +24,8 @@ public enum AuthServiceError: LocalizedError {
2424
2525 public var errorDescription : String ? {
2626 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
2929 case let . notConfiguredProvider( description) :
3030 return description
3131 case let . clientIdNotFound( description) :
Original file line number Diff line number Diff line change @@ -302,12 +302,20 @@ public extension AuthService {
302302 func handleSignInLink( url url: URL ) async throws {
303303 do {
304304 guard let email = emailLink else {
305- throw AuthServiceError . invalidEmailLink
305+ throw AuthServiceError . invalidEmailLink ( " email address is missing from local storage " )
306306 }
307307 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+ }
308313
309314 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+ )
311319 if shouldHandleAnonymousUpgrade, anonymousUserID == currentUser? . uid {
312320 let credential = EmailAuthProvider . credential ( withEmail: email, link: link)
313321 try await handleAutoUpgradeAnonymousUser ( credentials: credential)
Original file line number Diff line number Diff line change @@ -54,9 +54,4 @@ public class CommonUtils {
5454
5555 return urlComponents. queryItems? . first ( where: { $0. name == paramName } ) ? . value
5656 }
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- }
6257}
You can’t perform that action at this time.
0 commit comments