diff --git a/www/runtest.php b/www/runtest.php index 485ec2770b..884f3b8cf6 100644 --- a/www/runtest.php +++ b/www/runtest.php @@ -900,6 +900,13 @@ function buildSelfHost($hosts) return $selfHostScript; } +$isFree = !is_null($request_context->getUser()) && $request_context->getUser()->isFree(); + +// Allow free user to run test only if email is verified +if ($isFree && !$request_context->getUser()->isVerified()) { + $errorTitle = 'Email address is not verified'; + $error = 'Please verify your email address to use WebPageTest.'; +} if (!strlen($error) && CheckIp($test) && CheckUrl($test['url']) && CheckRateLimit($test, $error, $errorTitle)) { $total_runs = Util::getRunCount($test['runs'], $test['fvonly'], $test['lighthouse'], $test['type']); diff --git a/www/src/User.php b/www/src/User.php index 589b73fe2a..8bf27cda3d 100644 --- a/www/src/User.php +++ b/www/src/User.php @@ -89,6 +89,11 @@ public function isPaid(): bool ($this->payment_status == 'ACTIVE' || $this->isPendingCancelation()); } + public function isFree(): bool + { + return !$this->isPaid() && !$this->isAnon(); + } + public function setPaidClient(bool $is_paid): void { $this->is_paid_cp_client = $is_paid;