Support special characters in database password, closes #1508

This commit is contained in:
Dane Everitt 2019-08-03 14:42:32 -07:00
parent e7e41d8ee8
commit eb81e1ed20
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
6 changed files with 49 additions and 52 deletions

View file

@ -589,8 +589,7 @@ class ServersController extends Controller
* @param int $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Exception
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Throwable
*/
public function resetDatabasePassword(Request $request, $server)
{
@ -599,7 +598,7 @@ class ServersController extends Controller
['id', '=', $request->input('database')],
]);
$this->databasePasswordService->handle($database, str_random(24));
$this->databasePasswordService->handle($database);
return response('', 204);
}

View file

@ -87,12 +87,11 @@ class DatabaseController extends ApplicationApiController
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\ServerDatabaseWriteRequest $request
* @return \Illuminate\Http\Response
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Throwable
*/
public function resetPassword(ServerDatabaseWriteRequest $request): Response
{
$this->databasePasswordService->handle($request->getModel(Database::class), str_random(24));
$this->databasePasswordService->handle($request->getModel(Database::class));
return response('', 204);
}

View file

@ -135,15 +135,13 @@ class DatabaseController extends Controller
* @return \Illuminate\Http\JsonResponse
*
* @throws \Illuminate\Auth\Access\AuthorizationException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Throwable
*/
public function update(Request $request): JsonResponse
{
$this->authorize('reset-db-password', $request->attributes->get('server'));
$password = str_random(24);
$this->passwordService->handle($request->attributes->get('database'), $password);
$password = $this->passwordService->handle($request->attributes->get('database'));
return response()->json(['password' => $password]);
}