-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat(auth): add reauthentication flow with automatic operation retry #2332
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
base: version-10.0.0-beta03
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,7 +61,7 @@ internal fun FirebaseAuthUI.rememberOAuthSignInHandler( | |
| "Ensure FirebaseAuthScreen is used within an Activity." | ||
| ) | ||
|
|
||
| return remember(this, provider.providerId) { | ||
| return remember(this, provider.providerId, config) { | ||
| { | ||
| coroutineScope.launch { | ||
| try { | ||
|
|
@@ -165,11 +165,14 @@ internal suspend fun FirebaseAuthUI.signInWithProvider( | |
| return | ||
| } | ||
|
|
||
| // Determine if we should upgrade anonymous user or do normal sign-in | ||
| val authResult = if (canUpgradeAnonymous(config, auth)) { | ||
| auth.currentUser?.startActivityForLinkWithProvider(activity, oauthProvider)?.await() | ||
| } else { | ||
| auth.startActivityForSignInWithProvider(activity, oauthProvider).await() | ||
| // Determine if we should upgrade anonymous user, reauthenticate, or do normal sign-in | ||
| val authResult = when { | ||
| canUpgradeAnonymous(config, auth) -> | ||
| auth.currentUser?.startActivityForLinkWithProvider(activity, oauthProvider)?.await() | ||
| config.isReauthenticationMode -> | ||
| auth.currentUser!!.startActivityForReauthenticateWithProvider(activity, oauthProvider).await() | ||
|
Comment on lines
+172
to
+173
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the double-bang operator ( config.isReauthenticationMode -> {
val currentUser = auth.currentUser ?: throw AuthException.UserNotFoundException(
message = \"No user is currently signed in for reauthentication\"
)
currentUser.startActivityForReauthenticateWithProvider(activity, oauthProvider).await()
} |
||
| else -> | ||
| auth.startActivityForSignInWithProvider(activity, oauthProvider).await() | ||
| } | ||
|
|
||
| // Extract OAuth credential and complete sign-in | ||
|
|
||
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.
Using the double-bang operator (
!!) onauth.currentUseris unsafe and can lead to aNullPointerExceptionif the user session is concurrently cleared or invalidated. It is safer to use a defensive null check and throw a descriptiveAuthException.UserNotFoundExceptionif the user is null.