async function postLogin(body) {
  const res = await fetch('http://127.0.0.1:5000/api/auth/login', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(body),
  });
  const data = await res.json().catch(() => ({}));
  return {
    status: res.status,
    ok: res.ok,
    error: data.error || null,
    user: data.user ? {
      id: data.user.id,
      email: data.user.email,
      nickname: data.user.nickname,
      role: data.user.role,
    } : null,
    hasToken: Boolean(data.session?.access_token),
  };
}

(async () => {
  const results = {
    adminDefaultPassword: await postLogin({
      account: 'admin',
      password: 'admin123',
    }),
    missingHashOldUserWrongPassword: await postLogin({
      account: 'huangjj_0912@163.com',
      password: 'definitely-wrong-password',
    }),
    existingHashedUserWrongPassword: await postLogin({
      account: 'codex_profile_test_20260428@example.com',
      password: 'definitely-wrong-password',
    }),
  };
  console.log(JSON.stringify(results, null, 2));
})().catch(error => {
  console.error(error);
  process.exit(1);
});
