AuthUser
Represents an authenticated user with basic profile information.
This is a simplified user model extracted from Firebase Authentication that contains only the essential user information needed by the application. It serves as a layer of abstraction between Firebase-specific types and your app's domain.
Usage in Repository
class AuthRepository @Inject constructor(
private val authDataSource: AuthDataSource
) {
suspend fun signIn(email: String, password: String): Result<AuthUser> =
suspendRunCatching {
authDataSource.signInWithEmailAndPassword(email, password)
}
fun getCurrentUser(): AuthUser? = authDataSource.getCurrentUser()
}Content copied to clipboard
Usage in ViewModel
@HiltViewModel
class ProfileViewModel @Inject constructor(
private val authRepository: AuthRepository
) : ViewModel() {
val currentUser: AuthUser? = authRepository.getCurrentUser()
fun loadProfile() {
currentUser?.let { user ->
// Use user.id, user.name, user.profilePictureUri
}
}
}Content copied to clipboard
See also
FirebaseUser