let users = [
  { id: 1, username: 'test', password: '123456', email: 'test@example.com', firstName: 'Test', lastName: 'User' }
];
let nextId = 2;

exports.findUser = (username, email, password) =>
  users.find(u => (u.username === username || u.email === email) && u.password === password);

exports.findById = (id) => users.find(u => u.id === id);

exports.addUser = ({ username, password, email, firstName, lastName }) => {
  const newUser = { id: nextId++, username, password, email, firstName, lastName };
  users.push(newUser);
  return newUser;
};

exports.exists = (username, email) =>
  users.some(u => u.username === username || u.email === email);

exports.getAll = () => users; 