mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-13 11:53:45 +02:00
add ability to generate a token to retrieve the config for a specific node
This commit is contained in:
@@ -28,6 +28,7 @@ use DB;
|
||||
use Log;
|
||||
use Alert;
|
||||
use Validator;
|
||||
use Carbon\Carbon;
|
||||
use Pterodactyl\Models;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
@@ -276,4 +277,24 @@ class NodesController extends Controller
|
||||
'tab' => 'tab_delete',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getConfigurationToken(Request $request, $id) {
|
||||
// Check if Node exists. Will lead to 404 if not.
|
||||
Models\Node::findOrFail($id);
|
||||
|
||||
// Create a token
|
||||
$token = new Models\NodeConfigurationToken();
|
||||
$token->node = $id;
|
||||
$token->token = str_random(32);
|
||||
$token->expires_at = Carbon::now()->addMinutes(5); // Expire in 5 Minutes
|
||||
$token->save();
|
||||
|
||||
$token_response = array(
|
||||
'token' => $token->token,
|
||||
'expires_at' => $token->expires_at->toDateTimeString()
|
||||
);
|
||||
|
||||
return response(json_encode($token_response), 200)
|
||||
->header('Content-Type', 'application/json');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user