diff --git a/app/Ninja/Repositories/AccountRepository.php b/app/Ninja/Repositories/AccountRepository.php index 236f340e164c..752d08d755ac 100644 --- a/app/Ninja/Repositories/AccountRepository.php +++ b/app/Ninja/Repositories/AccountRepository.php @@ -32,6 +32,10 @@ class AccountRepository public function create($firstName = '', $lastName = '', $email = '', $password = '', $company = false) { if (! $company) { + if (Utils::isNinja()) { + $this->checkForSpammer(); + } + $company = new Company(); $company->utm_source = Input::get('utm_source'); $company->utm_medium = Input::get('utm_medium'); @@ -122,6 +126,23 @@ class AccountRepository return $account; } + private function checkForSpammer() + { + $ip = Request::getClientIp(); + $count = Account::whereIp($ip)->count(); + + if ($count > 1 && $errorEmail = env('ERROR_EMAIL')) { + \Mail::raw($ip, function ($message) use ($ip, $errorEmail) { + $message->to($errorEmail) + ->from(CONTACT_EMAIL) + ->subject('Duplicate company for IP: ' . $ip); + }); + if ($count >= 5) { + abort(); + } + } + } + public function getSearchData($user) { $data = $this->getAccountSearchData($user);