email ?? '')); $password = (string)($body->password ?? ''); $stmt = $pdo->prepare('SELECT id, pass_hash FROM users WHERE email = ?'); $stmt->execute([$email]); $user = $stmt->fetch(); if (!is_array($user) || !password_verify($password, (string)$user['pass_hash'])) { error_out(401, 'unauthorized'); } rate_clear($pdo, $ip, 'login'); login_user((int)$user['id']); json_out(['ok' => true]); } catch (Throwable $e) { error_log('login: ' . $e->getMessage()); error_out(500, 'internal'); }