Add database password change support and fix column name
This commit is contained in:
parent
0d61c50dcc
commit
5233d6e87b
11 changed files with 188 additions and 9 deletions
|
@ -25,6 +25,7 @@ namespace Pterodactyl\Http\Controllers\Server;
|
|||
|
||||
use Log;
|
||||
use Debugbar;
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\Node;
|
||||
|
||||
|
@ -223,4 +224,28 @@ class AjaxController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function postResetDatabasePassword(Request $request, $uuid)
|
||||
{
|
||||
$server = Models\Server::getByUUID($uuid);
|
||||
$database = Models\Database::where('id', $request->input('database'))->where('server_id', $server->id)->firstOrFail();
|
||||
|
||||
$this->authorize('reset-db-password', $server);
|
||||
try {
|
||||
|
||||
$repo = new Repositories\DatabaseRepository;
|
||||
$password = str_random(16);
|
||||
$repo->modifyPassword($request->input('database'), $password);
|
||||
return response($password);
|
||||
} catch (\Pterodactyl\Exceptions\DisplayException $ex) {
|
||||
return response()->json([
|
||||
'error' => $ex->getMessage(),
|
||||
], 503);
|
||||
} catch(\Exception $ex) {
|
||||
Log::error($ex);
|
||||
return response()->json([
|
||||
'error' => 'An unhandled error occured while attempting to modify this database\'s password.'
|
||||
], 503);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue