loginUser

fun loginUser()

Initiates the user login process based on the provided email and password in the current state.

This function performs validation on the provided email and password using the specified validators. If validation fails, it updates the state with corresponding error messages and returns. If validation succeeds, it calls the loginUseCase to initiate the login process.

The function observes the login process and updates the state accordingly based on the result:

  • If the login is successful (Resource.Success), it updates the state with the authenticated user.

  • If an error occurs during login (Resource.Error), it updates the state with the error message.

  • During the loading phase (Resource.Loading), it updates the state to indicate loading.

Throws

if the loginUseCase is not provided or initialized.