Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/UsersController.php
Show First 20 Lines • Show All 623 Lines • ▼ Show 20 Lines | public static function validateEmail( | ||||
bool $is_alias = false | bool $is_alias = false | ||||
): ?string { | ): ?string { | ||||
$attribute = $is_alias ? 'alias' : 'email'; | $attribute = $is_alias ? 'alias' : 'email'; | ||||
if (strpos($email, '@') === false) { | if (strpos($email, '@') === false) { | ||||
return \trans('validation.entryinvalid', ['attribute' => $attribute]); | return \trans('validation.entryinvalid', ['attribute' => $attribute]); | ||||
} | } | ||||
list($login, $domain) = explode('@', $email); | list($login, $domain) = explode('@', Str::lower($email)); | ||||
if (strlen($login) === 0 || strlen($domain) === 0) { | if (strlen($login) === 0 || strlen($domain) === 0) { | ||||
return \trans('validation.entryinvalid', ['attribute' => $attribute]); | return \trans('validation.entryinvalid', ['attribute' => $attribute]); | ||||
} | } | ||||
// Check if domain exists | // Check if domain exists | ||||
$domain = Domain::where('namespace', Str::lower($domain))->first(); | $domain = Domain::where('namespace', $domain)->first(); | ||||
if (empty($domain)) { | if (empty($domain)) { | ||||
return \trans('validation.domaininvalid'); | return \trans('validation.domaininvalid'); | ||||
} | } | ||||
// Validate login part alone | // Validate login part alone | ||||
$v = Validator::make( | $v = Validator::make( | ||||
[$attribute => $login], | [$attribute => $login], | ||||
Show All 32 Lines |