mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-29 16:00:45 +00:00
Improve username validation error for restricted names
This commit is contained in:
parent
4762efe8ee
commit
693f530326
1 changed files with 5 additions and 10 deletions
|
@ -58,7 +58,6 @@ class RegisterController extends Controller
|
|||
$data['email'] = strtolower($data['email']);
|
||||
}
|
||||
|
||||
$this->validateUsername($data['username']);
|
||||
$this->validateEmail($data['email']);
|
||||
|
||||
$usernameRules = [
|
||||
|
@ -87,6 +86,11 @@ class RegisterController extends Controller
|
|||
if(!ctype_alnum($val)) {
|
||||
return $fail('Username is invalid. Username must be alpha-numeric and may contain dashes (-), periods (.) and underscores (_).');
|
||||
}
|
||||
|
||||
$restricted = RestrictedNames::get();
|
||||
if (in_array($value, $restricted)) {
|
||||
return $fail('Username cannot be used.');
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -123,15 +127,6 @@ class RegisterController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
public function validateUsername($username)
|
||||
{
|
||||
$restricted = RestrictedNames::get();
|
||||
|
||||
if (in_array($username, $restricted)) {
|
||||
return abort(403);
|
||||
}
|
||||
}
|
||||
|
||||
public function validateEmail($email)
|
||||
{
|
||||
$banned = EmailService::isBanned($email);
|
||||
|
|
Loading…
Reference in a new issue