File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ public struct AccountMergeConflictContext: LocalizedError {
1313}
1414
1515public enum AuthServiceError : LocalizedError {
16+ case noCurrentUser
1617 case invalidEmailLink( String )
1718 case notConfiguredProvider( String )
1819 case clientIdNotFound( String )
@@ -24,6 +25,8 @@ public enum AuthServiceError: LocalizedError {
2425
2526 public var errorDescription : String ? {
2627 switch self {
28+ case . noCurrentUser:
29+ return " No user is currently signed in. "
2730 case let . invalidEmailLink( description) :
2831 return description
2932 case let . notConfiguredProvider( description) :
Original file line number Diff line number Diff line change @@ -180,7 +180,10 @@ public final class AuthService {
180180 }
181181 }
182182
183- public func handleAutoUpgradeAnonymousUser( credentials credentials: AuthCredential ) async throws {
183+ public func handleAutoUpgradeAnonymousUser( credentials: AuthCredential ) async throws {
184+ if currentUser == nil {
185+ throw AuthServiceError . noCurrentUser
186+ }
184187 do {
185188 try await currentUser? . link ( with: credentials)
186189 } catch let error as NSError {
@@ -196,7 +199,7 @@ public final class AuthService {
196199 }
197200 }
198201
199- public func signIn( credentials credentials : AuthCredential ) async throws {
202+ public func signIn( credentials: AuthCredential ) async throws {
200203 authenticationState = . authenticating
201204 do {
202205 if shouldHandleAnonymousUpgrade {
You can’t perform that action at this time.
0 commit comments