Skip to content

Commit 21759b4

Browse files
committed
wip: Email link, deep link
1 parent 9fe6660 commit 21759b4

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

auth/src/main/java/com/firebase/ui/auth/compose/ui/components/ErrorRecoveryDialog.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import com.firebase.ui.auth.compose.configuration.string_provider.AuthUIStringPr
6565
fun ErrorRecoveryDialog(
6666
error: AuthException,
6767
stringProvider: AuthUIStringProvider,
68-
onRetry: () -> Unit,
68+
onRetry: (AuthException) -> Unit,
6969
onDismiss: () -> Unit,
7070
modifier: Modifier = Modifier,
7171
onRecover: ((AuthException) -> Unit)? = null,
@@ -90,7 +90,7 @@ fun ErrorRecoveryDialog(
9090
if (isRecoverable(error)) {
9191
TextButton(
9292
onClick = {
93-
onRecover?.invoke(error) ?: onRetry()
93+
onRecover?.invoke(error) ?: onRetry(error)
9494
}
9595
) {
9696
Text(

auth/src/main/java/com/firebase/ui/auth/compose/ui/screens/EmailAuthScreen.kt

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import android.util.Log
55
import androidx.compose.runtime.Composable
66
import androidx.compose.runtime.LaunchedEffect
77
import androidx.compose.runtime.collectAsState
8-
import androidx.compose.runtime.derivedStateOf
98
import androidx.compose.runtime.getValue
109
import androidx.compose.runtime.mutableStateOf
1110
import androidx.compose.runtime.remember
@@ -118,6 +117,7 @@ fun EmailAuthScreen(
118117
val passwordTextValue = rememberSaveable { mutableStateOf("") }
119118
val confirmPasswordTextValue = rememberSaveable { mutableStateOf("") }
120119

120+
// Used for clearing text fields when switching EmailAuthMode changes
121121
val textValues = listOf(
122122
displayNameValue,
123123
emailTextValue,
@@ -222,7 +222,7 @@ fun EmailAuthScreen(
222222
try {
223223
authUI.sendPasswordResetEmail(
224224
email = emailTextValue.value,
225-
actionCodeSettings = null,
225+
actionCodeSettings = configuration.passwordResetActionCodeSettings,
226226
)
227227
} catch (e: Exception) {
228228

@@ -245,25 +245,31 @@ fun EmailAuthScreen(
245245

246246
if (isErrorDialogVisible.value) {
247247
ErrorRecoveryDialog(
248-
error = if ((authState as AuthState.Error).exception is AuthException)
249-
(authState as AuthState.Error).exception as AuthException else
250-
AuthException.from((authState as AuthState.Error).exception),
251-
stringProvider = stringProvider,
252-
onRetry = {
253-
// TODO(demolaf): EmailAuthScreen ErrorRecoveryDialog (onRetry) - handle retry
254-
// for failed action
255-
isErrorDialogVisible.value = false
256-
},
257-
onDismiss = {
258-
isErrorDialogVisible.value = false
248+
error = when ((authState as AuthState.Error).exception) {
249+
is AuthException -> {
250+
(authState as AuthState.Error).exception as AuthException
251+
}
252+
253+
else -> {
254+
AuthException
255+
.from((authState as AuthState.Error).exception)
256+
}
259257
},
260-
onRecover = { exception ->
258+
stringProvider = stringProvider,
259+
onRetry = { exception ->
261260
when (exception) {
261+
is AuthException.InvalidCredentialsException -> {
262+
state.onSignInClick()
263+
}
264+
262265
is AuthException.EmailAlreadyInUseException -> {
263266
state.onGoToSignIn()
264-
isErrorDialogVisible.value = false
265267
}
266268
}
269+
isErrorDialogVisible.value = false
270+
},
271+
onDismiss = {
272+
isErrorDialogVisible.value = false
267273
},
268274
)
269275
}

composeapp/src/main/java/com/firebase/composeapp/MainActivity.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ class MainActivity : ComponentActivity() {
2727
isDisplayNameRequired = true,
2828
// isEmailLinkSignInEnabled = true,
2929
isEmailLinkForceSameDeviceEnabled = true,
30-
actionCodeSettings = null,
30+
actionCodeSettings = actionCodeSettings {
31+
url = "https://example.com/verify"
32+
handleCodeInApp = true
33+
},
3134
isNewAccountsAllowed = true,
3235
minimumPasswordLength = 8,
3336
passwordValidationRules = listOf(
@@ -42,10 +45,6 @@ class MainActivity : ComponentActivity() {
4245
providers { provider(provider) }
4346
tosUrl = "https://www.google.com"
4447
privacyPolicyUrl = "https://www.google.com"
45-
passwordResetActionCodeSettings = actionCodeSettings {
46-
url = "https://example.com/verify"
47-
handleCodeInApp = true
48-
}
4948
}
5049

5150
setContent {

0 commit comments

Comments
 (0)