Use cache helpers rather than database to handle configuration tokens and downloads.

This commit is contained in:
Dane Everitt 2017-05-01 14:21:18 -04:00
parent 2330c25a8c
commit 605c91a9af
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
11 changed files with 95 additions and 146 deletions

View file

@ -25,8 +25,8 @@
namespace Pterodactyl\Http\Controllers\Server;
use Log;
use Uuid;
use Alert;
use Cache;
use Pterodactyl\Models;
use Illuminate\Http\Request;
use Pterodactyl\Exceptions\DisplayException;
@ -201,13 +201,11 @@ class ServerController extends Controller
$server = Models\Server::byUuid($uuid);
$this->authorize('download-files', $server);
$download = new Models\Download;
$download->token = (string) Uuid::generate(4);
$download->server = $server->uuid;
$download->path = $file;
$download->save();
$token = str_random(40);
Cache::tags(['Downloads', 'Downloads:Server:' . $server->uuid])->put('Download:' . $token, [
'server' => $server->uuid,
'path' => $file,
], 1);
return redirect($server->node->scheme . '://' . $server->node->fqdn . ':' . $server->node->daemonListen . '/server/file/download/' . $download->token);
}