Skip to content

Conversation

demolaf
Copy link

@demolaf demolaf commented Sep 15, 2025

  • Add AuthUIConfiguration data class with all properties
  • Implement authUIConfiguration DSL builder function
  • Add AuthProvider, AuthUITheme, AuthUIStringProvider, and PasswordRule models
  • Create comprehensive tests for default and custom configurations

@demolaf demolaf marked this pull request as draft September 15, 2025 14:16
@demolaf demolaf marked this pull request as ready for review September 15, 2025 14:17
import kotlin.reflect.KMutableProperty
import kotlin.reflect.full.memberProperties

class AuthUIConfigurationTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like to see a test for the Builder pattern as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if i understand, doesn't the authUIConfiguration dsl function tests handle the builder pattern test also?

/**
* The expected length of the SMS verification code. Defaults to 6.
*/
val smsCodeLength: Int = 6,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this verified against what we get from Firebase by default?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got this from the API Design docs, is there somewhere else I could check this from?

Comment on lines +25 to +40
interface AuthUIStringProvider {
fun initializing(): String
fun signInWithGoogle(): String
fun invalidEmail(): String
fun passwordsDoNotMatch(): String
}

class DefaultAuthUIStringProvider(private val context: Context) : AuthUIStringProvider {
override fun initializing(): String = ""

override fun signInWithGoogle(): String =
context.getString(R.string.fui_sign_in_with_google)

override fun invalidEmail(): String = ""

override fun passwordsDoNotMatch(): String = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need documentation for this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's a different ticket here

Comment on lines 21 to 52
sealed class PasswordRule {
/**
* Requires the password to have at least a certain number of characters.
*/
data class MinimumLength(val value: Int) : PasswordRule()

/**
* Requires the password to contain at least one uppercase letter (A-Z).
*/
object RequireUppercase : PasswordRule()

/**
* Requires the password to contain at least one lowercase letter (a-z).
*/
object RequireLowercase: PasswordRule()

/**
* Requires the password to contain at least one numeric digit (0-9).
*/
object RequireDigit: PasswordRule()

/**
* Requires the password to contain at least one special character (e.g., !@#$%^&*).
*/
object RequireSpecialCharacter: PasswordRule()

/**
* Defines a custom validation rule using a regular expression and provides a specific error
* message on failure.
*/
data class Custom(val regex: Regex, val errorMessage: String)
} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have the actual validation inside of this sealed class (maybe even something that can validate a list of PasswordRules

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is a different ticket too here, don't want to cramp them all in a single PR.

@Lyokone Lyokone merged commit ed436cf into firebase:version-10.0.0-dev Sep 19, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants