feat: anonymous account upgrade with error handling#1247
feat: anonymous account upgrade with error handling#1247russellwheatley merged 13 commits intomainfrom
Conversation
morganchen12
left a comment
There was a problem hiding this comment.
LGTM other than the one comment.
|
|
||
| public func handleAutoUpgradeAnonymousUser(credentials credentials: AuthCredential) async throws { | ||
| do { | ||
| try await currentUser?.link(with: credentials) |
There was a problem hiding this comment.
We should handle the currentUser null state in a separate conditional, otherwise this do-catch has the possibility of executing nothing and returning no error. From a convenience perspective it may also be nice to pass the unwrapped user through to the AccoutMergeConflictContext so the consumer doesn't have to again unwrap currentUser.
In theory currentUser should never be null here, so throwing an error is appropriate.
There was a problem hiding this comment.
@morganchen12 - updated. I didn't add User to the exception as it produced an Xcode compiler error: Stored property 'user' of 'Sendable'-conforming struct 'AccountMergeConflictContext' has non-sendable type 'User'
It seems User is non-sendable.
There was a problem hiding this comment.
A fix for that is in the pipeline in upstream Firebase, so maybe leave a TODO and just send the user's UID (String) for now?
Notes
email-already-in-uselike in the current FirebaseUI Auth. This is logic is duplicated in a few place in previous implementation but is handled in one spot for FUIAuth SwiftUI.Questions
email-linkisn't in app storage, we throw an error here: https://github.com/firebase/FirebaseUI-iOS/pull/1247/files#diff-659d4c231d40710232200eb4482235de5964068a1395944bc32983fe0ed8670cR305. We could just push user back to email link sign-in View if it isn't present.