Changeset View
Changeset View
Standalone View
Standalone View
src/app/Rules/SignupExternalEmail.php
Show All 18 Lines | public function passes($attribute, $email): bool | ||||
if (strlen($email) > 191) { | if (strlen($email) > 191) { | ||||
$this->message = \trans('validation.emailinvalid'); | $this->message = \trans('validation.emailinvalid'); | ||||
return false; | return false; | ||||
} | } | ||||
// Don't allow multiple open registrations against the same email address | // Don't allow multiple open registrations against the same email address | ||||
if (($limit = \config('app.signup.email_limit')) > 0) { | if (($limit = \config('app.signup.email_limit')) > 0) { | ||||
$signups = SignupCode::where('email', $email) | $signups = SignupCode::where('email', $email) | ||||
->whereDate('expires_at', '>', \Carbon\Carbon::now()); | ->where('expires_at', '>', \Carbon\Carbon::now()); | ||||
if ($signups->count() >= $limit) { | if ($signups->count() >= $limit) { | ||||
// @kanarip: this is deliberately an "email invalid" message | // @kanarip: this is deliberately an "email invalid" message | ||||
$this->message = \trans('validation.emailinvalid'); | $this->message = \trans('validation.emailinvalid'); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
// Don't allow multiple open registrations against the same source ip address | // Don't allow multiple open registrations against the same source ip address | ||||
if (($limit = \config('app.signup.ip_limit')) > 0) { | if (($limit = \config('app.signup.ip_limit')) > 0) { | ||||
$signups = SignupCode::where('ip_address', request()->ip()) | $signups = SignupCode::where('ip_address', request()->ip()) | ||||
->whereDate('expires_at', '>', \Carbon\Carbon::now()); | ->where('expires_at', '>', \Carbon\Carbon::now()); | ||||
if ($signups->count() >= $limit) { | if ($signups->count() >= $limit) { | ||||
// @kanarip: this is deliberately an "email invalid" message | // @kanarip: this is deliberately an "email invalid" message | ||||
$this->message = \trans('validation.emailinvalid'); | $this->message = \trans('validation.emailinvalid'); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
} | } |