|
2 | 2 |
|
3 | 3 | namespace Pterodactyl\Services\Databases; |
4 | 4 |
|
5 | | -use Exception; |
6 | 5 | use Pterodactyl\Models\Database; |
7 | | -use Illuminate\Support\Facades\Log; |
| 6 | +use Pterodactyl\Helpers\Utilities; |
8 | 7 | use Illuminate\Database\ConnectionInterface; |
9 | 8 | use Illuminate\Contracts\Encryption\Encrypter; |
10 | 9 | use Pterodactyl\Extensions\DynamicDatabaseConnection; |
@@ -62,19 +61,7 @@ public function __construct( |
62 | 61 | */ |
63 | 62 | public function handle(Database $database): string |
64 | 63 | { |
65 | | - $password = str_random(24); |
66 | | - // Given a random string of characters, randomly loop through the characters and replace some |
67 | | - // with special characters to avoid issues with MySQL password requirements on some servers. |
68 | | - try { |
69 | | - for ($i = 0; $i < random_int(2, 6); $i++) { |
70 | | - $character = ['!', '@', '=', '.', '+', '^'][random_int(0, 5)]; |
71 | | - |
72 | | - $password = substr_replace($password, $character, random_int(0, 23), 1); |
73 | | - } |
74 | | - } catch (Exception $exception) { |
75 | | - // Just log the error and hope for the best at this point. |
76 | | - Log::error($exception); |
77 | | - } |
| 64 | + $password = Utilities::randomStringWithSpecialCharacters(24); |
78 | 65 |
|
79 | 66 | $this->connection->transaction(function () use ($database, $password) { |
80 | 67 | $this->dynamic->set('dynamic', $database->database_host_id); |
|
0 commit comments