Changeset View
Changeset View
Standalone View
Standalone View
src/app/Rules/ExternalEmail.php
Show All 31 Lines | public function passes($attribute, $email): bool | ||||
list($local, $domain) = explode('@', $email); | list($local, $domain) = explode('@', $email); | ||||
// don't allow @localhost and other no-fqdn | // don't allow @localhost and other no-fqdn | ||||
if (strpos($domain, '.') === false) { | if (strpos($domain, '.') === false) { | ||||
$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 | |||||
if (env('SIGNUP_LIMIT_EMAIL', 0) > 0) { | |||||
machniak: ExternalEmail rule is also used to validate group (distlist) members. And is not, but actually… | |||||
vanmeeuwenAuthorUnsubmitted Done Inline ActionsThen where should they be? vanmeeuwen: Then where should they be? | |||||
machniakUnsubmitted Not Done Inline ActionsEither in another rule class or in the SignupController. machniak: Either in another rule class or in the SignupController. | |||||
$signups = \App\SignupCode::where('email', $email) | |||||
->whereDate('expires_at', '>', \Carbon\Carbon::now()); | |||||
if ($signups->count() >= env('SIGNUP_LIMIT_EMAIL')) { | |||||
$this->message = \trans('validation.emailinvalid'); | |||||
mollekopfUnsubmitted Done Inline ActionsPerhaps add a comment that this is the same message on purpose, otherwise we're bound to "fix" this. mollekopf: Perhaps add a comment that this is the same message on purpose, otherwise we're bound to "fix"… | |||||
vanmeeuwenAuthorUnsubmitted Done Inline ActionsThis is apparently moving anyway. vanmeeuwen: This is apparently moving anyway. | |||||
machniakUnsubmitted Not Done Inline Actionsemailinvalid does not make sense in this case, indeed. machniak: `emailinvalid` does not make sense in this case, indeed. | |||||
return false; | |||||
} | |||||
} | |||||
// don't allow multiple open registrations against the same source ip address | |||||
if (env('SIGNUP_LIMIT_IP', 0) > 0) { | |||||
$signups = \App\SignupCode::where("ip_address", request()->ip()) | |||||
->whereDate('expires_at', '>', \Carbon\Carbon::now()); | |||||
if ($signups->count() >= env('SIGNUP_LIMIT_IP')) { | |||||
$this->message = \trans('validation.emailinvalid'); | |||||
return false; | |||||
} | |||||
} | |||||
return true; | return true; | ||||
} | } | ||||
/** | /** | ||||
* Get the validation error message. | * Get the validation error message. | ||||
* | * | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
public function message(): ?string | public function message(): ?string | ||||
{ | { | ||||
return $this->message; | return $this->message; | ||||
} | } | ||||
} | } |
ExternalEmail rule is also used to validate group (distlist) members. And is not, but actually should be used to validate user external email. So, doing the signup related checks here is not right.