-
Notifications
You must be signed in to change notification settings - Fork 484
feat: google reauthenticate logic for sensitive operations such as delete user #1258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Button(action: { | ||
withAnimation { | ||
switchFlow() | ||
ScrollView { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just added ScrollView here. Otherwise, cannot see all options.
} | ||
|
||
extension GoogleOperationReauthentication { | ||
@MainActor func reauthenticate() async throws -> AuthenticationToken { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follows near identical logic to Facebook for reauthentication.
try await self.signInWithGoogle(clientID: self.clientID) | ||
} | ||
}) | ||
AnyView(SignInWithGoogleButton()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this into separate View, it was directly calling signInWithGoogle which meant it wasn't actually signing in with Firebase and not using AuthService to update currentUser and other aspects of state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider documenting this in a comment since it's unintuitive looking at the code.
try await operation(on: user) | ||
} else if providerId == "facebook.com" { | ||
try await facebookProvider.deleteUser(user: user) | ||
} else if providerId == "google.com" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These string values should be vended by the upstream Auth SDK as constants if you'd like to use those instead of typing them out: https://firebase.google.com/docs/reference/ios/firebaseauth/api/reference/Constants#firgoogleauthproviderid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
try await self.signInWithGoogle(clientID: self.clientID) | ||
} | ||
}) | ||
AnyView(SignInWithGoogleButton()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider documenting this in a comment since it's unintuitive looking at the code.
Made some comments for ease of understanding.