AuthUser

data class AuthUser(val id: String, val name: String, val profilePictureUri: Uri?)

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()
}

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
}
}
}

See also

FirebaseUser

Constructors

Link copied to clipboard
constructor(id: String, name: String, profilePictureUri: Uri?)

Properties

Link copied to clipboard
val id: String

The unique identifier for the user (Firebase UID). This is stable across all authentication providers and should be used as the primary key for user-related data in databases.

Link copied to clipboard

The user's display name. May be empty if not provided during registration or if the authentication provider doesn't provide a name.

Link copied to clipboard

The URI for the user's profile picture, or null if not available. For Google Sign-In, this is typically the user's Google profile photo. For email/password, this is null unless explicitly set.