import '../models/user.dart';
import '../repositories/auth_repository.dart';

class AuthService {
  final AuthRepository _authRepository;

  AuthService(this._authRepository);

  Future<User> login(String email, String password) async {
    if (email.isEmpty || password.isEmpty) {
      throw Exception('Email and password are required');
    }
    if (!email.contains('@')) {
      throw Exception('Invalid email format');
    }
    return await _authRepository.login(email, password);
  }

  Future<void> logout() async {
    await _authRepository.logout();
  }

  Future<User?> getCurrentUser() async {
    return await _authRepository.getCurrentUser();
  }
}
