Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -509,4 +509,7 @@ interface AuthUIStringProvider {

/** ToS and Privacy Policy combined message with placeholders for links */
fun tosAndPrivacyPolicy(termsOfServiceLabel: String, privacyPolicyLabel: String): String

/** Tooltip message shown when new account sign-up is disabled */
val newAccountsDisabledTooltip: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -466,4 +466,7 @@ class DefaultAuthUIStringProvider(

override fun tosAndPrivacyPolicy(termsOfServiceLabel: String, privacyPolicyLabel: String): String =
localizedContext.getString(R.string.fui_tos_and_pp, termsOfServiceLabel, privacyPolicyLabel)

override val newAccountsDisabledTooltip: String
get() = localizedContext.getString(R.string.fui_new_accounts_disabled_tooltip)
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ private fun getRecoveryActionText(
is AuthException.EmailLinkCrossDeviceLinkingException -> stringProvider.continueText
is AuthException.EmailLinkWrongDeviceException -> stringProvider.continueText
is AuthException.EmailLinkDifferentAnonymousUserException -> stringProvider.dismissAction
is AuthException.UserNotFoundException -> stringProvider.signupPageTitle // Navigate to sign-up when user not found
is AuthException.NetworkException,
is AuthException.InvalidCredentialsException,
is AuthException.UserNotFoundException,
is AuthException.WeakPasswordException,
is AuthException.TooManyRequestsException,
is AuthException.UnknownException -> stringProvider.retryAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,16 @@ fun EmailAuthScreen(
exception = exception,
onRetry = { ex ->
when (ex) {
is AuthException.UserNotFoundException -> {
val provider = configuration.providers
.filterIsInstance<AuthProvider.Email>()
.first()
if (provider.isNewAccountsAllowed) {
// User not found, but new accounts are allowed, switch to sign-up
mode.value = EmailAuthMode.SignUp
}
}

is AuthException.InvalidCredentialsException -> {
// User can retry sign in with corrected credentials
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,29 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.PlainTooltip
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TooltipAnchorPosition
import androidx.compose.material3.TooltipBox
import androidx.compose.material3.TooltipDefaults
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.rememberTooltipState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.semantics.heading
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.style.TextAlign
Expand All @@ -57,11 +60,13 @@ import androidx.compose.ui.unit.dp
import com.firebase.ui.auth.configuration.AuthUIConfiguration
import com.firebase.ui.auth.configuration.authUIConfiguration
import com.firebase.ui.auth.configuration.auth_provider.AuthProvider
import com.firebase.ui.auth.configuration.string_provider.DefaultAuthUIStringProvider
import com.firebase.ui.auth.configuration.string_provider.LocalAuthUIStringProvider
import com.firebase.ui.auth.configuration.theme.AuthUITheme
import com.firebase.ui.auth.configuration.validators.EmailValidator
import com.firebase.ui.auth.configuration.validators.PasswordValidator
import com.firebase.ui.auth.ui.components.AuthTextField
import com.firebase.ui.auth.ui.components.LocalTopLevelDialogController
import com.firebase.ui.auth.ui.components.TermsAndPrivacyForm

@OptIn(ExperimentalMaterial3Api::class)
Expand Down Expand Up @@ -175,20 +180,31 @@ fun SignInUI(
modifier = Modifier
.align(Alignment.End),
) {
Button(
onClick = {
onGoToSignUp()
TooltipBox(
positionProvider = TooltipDefaults.rememberTooltipPositionProvider(
TooltipAnchorPosition.Above
),
tooltip = {
PlainTooltip {
Text(stringProvider.newAccountsDisabledTooltip)
}
},
enabled = !isLoading,
state = rememberTooltipState(
initialIsVisible = !provider.isNewAccountsAllowed
)
) {
Text(stringProvider.signupPageTitle.uppercase())
Button(
onClick = {
onGoToSignUp()
},
enabled = provider.isNewAccountsAllowed && !isLoading,
) {
Text(stringProvider.signupPageTitle.uppercase())
}
}
Spacer(modifier = Modifier.width(16.dp))
Button(
onClick = {
// TODO(demolaf): When signIn is fired if Exception is UserNotFound
// then we check if provider.isNewAccountsAllowed then we show signUp
// else we show an error dialog stating signup is not allowed
onSignInClick()
},
enabled = !isLoading && isFormValid.value,
Expand Down Expand Up @@ -250,29 +266,34 @@ fun PreviewSignInUI() {
isEmailLinkSignInEnabled = false,
isEmailLinkForceSameDeviceEnabled = true,
emailLinkActionCodeSettings = null,
isNewAccountsAllowed = true,
isNewAccountsAllowed = false,
minimumPasswordLength = 8,
passwordValidationRules = listOf()
)
val stringProvider = DefaultAuthUIStringProvider(applicationContext)

AuthUITheme {
SignInUI(
configuration = authUIConfiguration {
context = applicationContext
providers { provider(provider) }
tosUrl = ""
privacyPolicyUrl = ""
},
email = "",
password = "",
isLoading = false,
emailSignInLinkSent = false,
onEmailChange = { email -> },
onPasswordChange = { password -> },
onSignInClick = {},
onGoToSignUp = {},
onGoToResetPassword = {},
onGoToEmailLinkSignIn = {},
)
CompositionLocalProvider(
LocalAuthUIStringProvider provides stringProvider
) {
SignInUI(
configuration = authUIConfiguration {
context = applicationContext
providers { provider(provider) }
tosUrl = ""
privacyPolicyUrl = ""
},
email = "",
password = "",
isLoading = false,
emailSignInLinkSent = false,
onEmailChange = { email -> },
onPasswordChange = { password -> },
onSignInClick = {},
onGoToSignUp = {},
onGoToResetPassword = {},
onGoToEmailLinkSignIn = {},
)
}
}
}
3 changes: 3 additions & 0 deletions auth/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,7 @@
<string name="fui_verified_email_action">البريد الإلكتروني محقق</string>
<string name="fui_verify_action">تحقق</string>
<string name="fui_verify_email_instruction">أرسلنا بريدًا للتحقق إلى %1$s</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-b+es+419/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,7 @@
<string name="fui_reauth_required_error">Se requiere reautenticación</string>
<string name="fui_reauth_success_message">Reautenticación exitosa</string>
<string name="fui_reauthenticate_action">Reautenticar</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-bg/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,7 @@
<string name="fui_verified_email_action">Имейлът е потвърден</string>
<string name="fui_verify_action">Потвърждаване</string>
<string name="fui_verify_email_instruction">Изпратихме имейл за потвърждение до %1$s</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-bn/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,7 @@
<string name="fui_verified_email_action">ইমেল যাচাই করা হয়েছে</string>
<string name="fui_verify_action">যাচাই করুন</string>
<string name="fui_verify_email_instruction">আমরা %1$s-এ একটি যাচাইকরণ ইমেল পাঠিয়েছি</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-ca/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,7 @@
<string name="fui_verified_email_action">Correu verificat</string>
<string name="fui_verify_action">Verifica</string>
<string name="fui_verify_email_instruction">Hem enviat un correu de verificació a %1$s</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,7 @@
<string name="fui_verified_email_action">E-mail ověřen</string>
<string name="fui_verify_action">Ověřit</string>
<string name="fui_verify_email_instruction">Odeslali jsme ověřovací e-mail na %1$s</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,7 @@
<string name="fui_verified_email_action">E-mail bekræftet</string>
<string name="fui_verify_action">Bekræft</string>
<string name="fui_verify_email_instruction">Vi har sendt en bekræftelsesemail til %1$s</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-de-rAT/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,7 @@
<string name="fui_reauth_required_error">Erneute Authentifizierung erforderlich</string>
<string name="fui_reauth_success_message">Erneute Authentifizierung erfolgreich</string>
<string name="fui_reauthenticate_action">Erneut authentifizieren</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-de-rCH/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,7 @@
<string name="fui_reauth_required_error">Erneute Authentifizierung erforderlich</string>
<string name="fui_reauth_success_message">Erneute Authentifizierung erfolgreich</string>
<string name="fui_reauthenticate_action">Erneut authentifizieren</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,7 @@
<string name="fui_reauth_required_error">Erneute Authentifizierung erforderlich</string>
<string name="fui_reauth_success_message">Erneute Authentifizierung erfolgreich</string>
<string name="fui_reauthenticate_action">Erneut authentifizieren</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,7 @@
<string name="fui_verified_email_action">Το email επαληθεύτηκε</string>
<string name="fui_verify_action">Επαλήθευση</string>
<string name="fui_verify_email_instruction">Στείλαμε email επαλήθευσης στο %1$s</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-en-rAU/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,7 @@
<string name="fui_verified_email_action">Email verified</string>
<string name="fui_verify_action">Verify</string>
<string name="fui_verify_email_instruction">We sent a verification email to %1$s</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-en-rCA/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,7 @@
<string name="fui_verified_email_action">Email verified</string>
<string name="fui_verify_action">Verify</string>
<string name="fui_verify_email_instruction">We sent a verification email to %1$s</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-en-rGB/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,7 @@
<string name="fui_verified_email_action">Email verified</string>
<string name="fui_verify_action">Verify</string>
<string name="fui_verify_email_instruction">We sent a verification email to %1$s</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-en-rIE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,7 @@
<string name="fui_verified_email_action">Email verified</string>
<string name="fui_verify_action">Verify</string>
<string name="fui_verify_email_instruction">We sent a verification email to %1$s</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-en-rIN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,7 @@
<string name="fui_verified_email_action">Email verified</string>
<string name="fui_verify_action">Verify</string>
<string name="fui_verify_email_instruction">We sent a verification email to %1$s</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-en-rSG/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,7 @@
<string name="fui_verified_email_action">Email verified</string>
<string name="fui_verify_action">Verify</string>
<string name="fui_verify_email_instruction">We sent a verification email to %1$s</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-en-rZA/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,7 @@
<string name="fui_verified_email_action">Email verified</string>
<string name="fui_verify_action">Verify</string>
<string name="fui_verify_email_instruction">We sent a verification email to %1$s</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-es-rAR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,7 @@
<string name="fui_reauth_required_error">Se requiere reautenticación</string>
<string name="fui_reauth_success_message">Reautenticación exitosa</string>
<string name="fui_reauthenticate_action">Reautenticar</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-es-rBO/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,7 @@
<string name="fui_reauth_required_error">Se requiere reautenticación</string>
<string name="fui_reauth_success_message">Reautenticación exitosa</string>
<string name="fui_reauthenticate_action">Reautenticar</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
3 changes: 3 additions & 0 deletions auth/src/main/res/values-es-rCL/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,7 @@
<string name="fui_reauth_required_error">Se requiere reautenticación</string>
<string name="fui_reauth_success_message">Reautenticación exitosa</string>
<string name="fui_reauthenticate_action">Reautenticar</string>

<!-- Tooltips -->
<string name="fui_new_accounts_disabled_tooltip" translation_description="Tooltip shown when sign-up button is disabled because new accounts are not allowed">This button is currently disabled because new accounts are not allowed</string>
</resources>
Loading
Loading