Fix username validation and auto-generation, closes #927
This commit is contained in:
parent
c3dc376c4c
commit
bf537922a3
7 changed files with 159 additions and 41 deletions
|
@ -10,6 +10,7 @@
|
|||
namespace Pterodactyl\Services\Subusers;
|
||||
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Rules\Username;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Pterodactyl\Services\Users\UserCreationService;
|
||||
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
||||
|
@ -117,9 +118,10 @@ class SubuserCreationService
|
|||
throw new ServerSubuserExistsException(trans('exceptions.subusers.subuser_exists'));
|
||||
}
|
||||
} catch (RecordNotFoundException $exception) {
|
||||
$username = preg_replace('/([^\w\.-]+)/', '', strtok($email, '@'));
|
||||
$user = $this->userCreationService->handle([
|
||||
'email' => $email,
|
||||
'username' => substr(strtok($email, '@'), 0, 8) . '_' . str_random(6),
|
||||
'username' => $username . str_random(3),
|
||||
'name_first' => 'Server',
|
||||
'name_last' => 'Subuser',
|
||||
'root_admin' => false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue