From 07eaf3c98960d2f74e71282bee6e530f3e24500e Mon Sep 17 00:00:00 2001 From: null Date: Wed, 1 Jul 2026 02:18:50 -0500 Subject: [PATCH] feat(auth): ChangePasswordException sealed class with typed failure reasons --- .../repository/ChangePasswordException.kt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 app/src/main/java/app/closer/domain/repository/ChangePasswordException.kt diff --git a/app/src/main/java/app/closer/domain/repository/ChangePasswordException.kt b/app/src/main/java/app/closer/domain/repository/ChangePasswordException.kt new file mode 100644 index 00000000..0e82d124 --- /dev/null +++ b/app/src/main/java/app/closer/domain/repository/ChangePasswordException.kt @@ -0,0 +1,23 @@ +package app.closer.domain.repository + +/** + * Typed reasons a signed-in password change can fail, mapped from Firebase specifics at the auth + * data-source boundary. Using these instead of matching on Firebase's human-readable error strings keeps + * detection robust across SDK/locale changes; the UI layer owns the user-facing copy per type. + */ +sealed class ChangePasswordException(message: String) : Exception(message) { + /** The current password entered for re-authentication was wrong. */ + class WrongCurrentPassword : ChangePasswordException("Current password incorrect") + + /** The new password doesn't meet Firebase's strength requirement. */ + class WeakNewPassword : ChangePasswordException("New password too weak") + + /** Firebase is throttling after too many attempts — back off and retry later. */ + class TooManyAttempts : ChangePasswordException("Too many attempts") + + /** The session is too old; the user must sign in again before changing the password. */ + class ReauthRequired : ChangePasswordException("Recent sign-in required") + + /** This account has no password to change (e.g. Google sign-in only). */ + class NoPassword : ChangePasswordException("Account has no password") +}