Truncate auto-generated usernames to 64 characters
This commit is contained in:
parent
c0fc9125ed
commit
711efe34bb
1 changed files with 6 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Pterodactyl\Services\Subusers;
|
namespace Pterodactyl\Services\Subusers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Pterodactyl\Models\Server;
|
use Pterodactyl\Models\Server;
|
||||||
use Pterodactyl\Models\Subuser;
|
use Pterodactyl\Models\Subuser;
|
||||||
use Illuminate\Database\ConnectionInterface;
|
use Illuminate\Database\ConnectionInterface;
|
||||||
|
@ -84,9 +85,13 @@ class SubuserCreationService
|
||||||
throw new ServerSubuserExistsException(trans('exceptions.subusers.subuser_exists'));
|
throw new ServerSubuserExistsException(trans('exceptions.subusers.subuser_exists'));
|
||||||
}
|
}
|
||||||
} catch (RecordNotFoundException $exception) {
|
} catch (RecordNotFoundException $exception) {
|
||||||
|
// Just cap the username generated at 64 characters at most and then append a random string
|
||||||
|
// to the end to make it "unique"...
|
||||||
|
$username = substr(preg_replace('/([^\w\.-]+)/', '', strtok($email, '@')), 0, 64) . Str::random(3);
|
||||||
|
|
||||||
$user = $this->userCreationService->handle([
|
$user = $this->userCreationService->handle([
|
||||||
'email' => $email,
|
'email' => $email,
|
||||||
'username' => preg_replace('/([^\w\.-]+)/', '', strtok($email, '@')) . str_random(3),
|
'username' => $username,
|
||||||
'name_first' => 'Server',
|
'name_first' => 'Server',
|
||||||
'name_last' => 'Subuser',
|
'name_last' => 'Subuser',
|
||||||
'root_admin' => false,
|
'root_admin' => false,
|
||||||
|
|
Loading…
Reference in a new issue