mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Update RegisterController, validate username against restricted names
This commit is contained in:
parent
594576185b
commit
91fd53a4be
1 changed files with 12 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Util\Lexer\RestrictedNames;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
@ -48,6 +49,8 @@ class RegisterController extends Controller
|
|||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
$this->validateUsername($data['username']);
|
||||
|
||||
return Validator::make($data, [
|
||||
'name' => 'required|string|max:255',
|
||||
'username' => 'required|alpha_dash|min:2|max:15|unique:users',
|
||||
|
@ -71,4 +74,13 @@ class RegisterController extends Controller
|
|||
'password' => Hash::make($data['password']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function validateUsername($username)
|
||||
{
|
||||
$restricted = RestrictedNames::get();
|
||||
|
||||
if(in_array($username, $restricted)) {
|
||||
return abort(403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue