package dev.service;

import dev.dao.UserDao;
import dev.model.User;

public class AuthService {

    private UserDao userDao = new UserDao();

    public boolean register(String username, String password, String email) {
        if (username == null || username.isEmpty() || password == null) {
            return false;
        }

        User user = new User();
        user.setUsername(username);
        user.setPassword(password);
        user.setEmail(email);

        return userDao.save(user);
    }

    public User login(String username, String password) {
        User user = userDao.findByUsername(username);

        if (user != null && user.getPassword().equals(password)) {
            return user;
        }
        return null;
    }
}