Skip to content

Commit ca88906

Browse files
committed
fix reviews
1 parent a9952cc commit ca88906

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

auth/src/main/java/com/firebase/ui/auth/configuration/auth_provider/EmailAuthProvider+FirebaseAuthUI.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ internal suspend fun FirebaseAuthUI.signInOrReauth(
5757
credential: AuthCredential,
5858
config: AuthUIConfiguration,
5959
): AuthResult? = if (config.isReauthenticationMode) {
60-
auth.currentUser!!.reauthenticate(credential).await()
60+
val currentUser = auth.currentUser
61+
?: throw AuthException.UserNotFoundException(message = "No user is currently signed in for reauthentication")
62+
currentUser.reauthenticate(credential).await()
6163
null
6264
} else {
6365
auth.signInWithCredential(credential).await()

auth/src/main/java/com/firebase/ui/auth/configuration/auth_provider/OAuthProvider+FirebaseAuthUI.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,11 @@ internal suspend fun FirebaseAuthUI.signInWithProvider(
169169
val authResult = when {
170170
canUpgradeAnonymous(config, auth) ->
171171
auth.currentUser?.startActivityForLinkWithProvider(activity, oauthProvider)?.await()
172-
config.isReauthenticationMode ->
173-
auth.currentUser!!.startActivityForReauthenticateWithProvider(activity, oauthProvider).await()
172+
config.isReauthenticationMode -> {
173+
val currentUser = auth.currentUser
174+
?: throw AuthException.UserNotFoundException(message = "No user is currently signed in for reauthentication")
175+
currentUser.startActivityForReauthenticateWithProvider(activity, oauthProvider).await()
176+
}
174177
else ->
175178
auth.startActivityForSignInWithProvider(activity, oauthProvider).await()
176179
}

auth/src/main/java/com/firebase/ui/auth/ui/screens/FirebaseAuthScreen.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,15 @@ fun FirebaseAuthScreen(
446446
// Lock the state to Loading before launching the retry so no
447447
// intermediate Success emission can navigate to AuthRoute.Success.
448448
authUI.updateAuthState(AuthState.Loading())
449-
coroutineScope.launch { retry(context) }
449+
coroutineScope.launch {
450+
try {
451+
retry(context)
452+
} catch (e: kotlinx.coroutines.CancellationException) {
453+
throw e
454+
} catch (e: Exception) {
455+
authUI.updateAuthState(AuthState.Error(e))
456+
}
457+
}
450458
return@LaunchedEffect
451459
}
452460

0 commit comments

Comments
 (0)