signIn method

Future<bool> signIn(
  1. String email,
  2. String password
)

Autentica al usuario y almacena la sesión.

Devuelve true si el login fue exitoso. En caso de error, establece errorMessage con el detalle.

Implementation

Future<bool> signIn(String email, String password) async {
  try {
    _isLoading = true;
    _errorMessage = null;
    notifyListeners();

    final response = await _authService.signIn(email, password);

    _userRole = response.role;
    _userName = response.name;
    _serviceId = response.serviceId;
    _userId = response.userId;

    return true;
  } catch (e) {
    if (e is AuthException) {
      _errorMessage = e.message;
    } else {
      _errorMessage = "Error de conexión inesperado";
    }
    return false;
  } finally {
    _isLoading = false;
    notifyListeners();
  }
}