Merge company creation check

This commit is contained in:
Hillel Coren 2018-03-11 09:21:49 +02:00
parent bcaad69d00
commit 77a2920538

View File

@ -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);