mirror of
https://github.com/YunoHost-Apps/pixelfed_ynh.git
synced 2024-09-03 20:06:04 +02:00
Improve email validation error for restricted emails
This commit is contained in:
parent
693f530326
commit
913bf77ba4
1 changed files with 15 additions and 11 deletions
|
@ -58,8 +58,6 @@ class RegisterController extends Controller
|
||||||
$data['email'] = strtolower($data['email']);
|
$data['email'] = strtolower($data['email']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->validateEmail($data['email']);
|
|
||||||
|
|
||||||
$usernameRules = [
|
$usernameRules = [
|
||||||
'required',
|
'required',
|
||||||
'min:2',
|
'min:2',
|
||||||
|
@ -94,11 +92,25 @@ class RegisterController extends Controller
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$emailRules = [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'email',
|
||||||
|
'max:255',
|
||||||
|
'unique:users',
|
||||||
|
function ($attribute, $value, $fail) {
|
||||||
|
$banned = EmailService::isBanned($value);
|
||||||
|
if($banned) {
|
||||||
|
return $fail('Email is invalid.');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
$rules = [
|
$rules = [
|
||||||
'agecheck' => 'required|accepted',
|
'agecheck' => 'required|accepted',
|
||||||
'name' => 'nullable|string|max:'.config('pixelfed.max_name_length'),
|
'name' => 'nullable|string|max:'.config('pixelfed.max_name_length'),
|
||||||
'username' => $usernameRules,
|
'username' => $usernameRules,
|
||||||
'email' => 'required|string|email|max:255|unique:users',
|
'email' => $emailRules,
|
||||||
'password' => 'required|string|min:12|confirmed',
|
'password' => 'required|string|min:12|confirmed',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -127,14 +139,6 @@ class RegisterController extends Controller
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateEmail($email)
|
|
||||||
{
|
|
||||||
$banned = EmailService::isBanned($email);
|
|
||||||
if($banned) {
|
|
||||||
return abort(403, 'Invalid email.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the application registration form.
|
* Show the application registration form.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue