package com.zyzf.coffeepreorder.ui.login

import androidx.lifecycle.ViewModel
import com.zyzf.coffeepreorder.database.model.User
import com.zyzf.coffeepreorder.database.repository.UserRepository

class LoginViewModel(
    private val userRepository: UserRepository
) : ViewModel() {
    suspend fun tryLogin(login: String, password: String): User? {
        val user: User? = userRepository.tryLogin(login, password)
        return if (user?.uid == 0) {
            null
        } else {
            user
        }
    }
}
