1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-10-27 20:32:28 +01:00

More model updates.

This commit is contained in:
Dane Everitt 2017-02-10 17:36:58 -05:00
parent 3b3002b77a
commit c70d31c08f
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
2 changed files with 7 additions and 13 deletions

View File

@ -118,8 +118,7 @@ class SecurityController extends Controller
public function revoke(Request $request, $id) public function revoke(Request $request, $id)
{ {
$session = Session::where('id', $id)->where('user_id', $request->user()->id)->firstOrFail(); Session::where('user_id', $request->user()->id)->findOrFail($id)->delete();
$session->delete();
return redirect()->route('account.security'); return redirect()->route('account.security');
} }

View File

@ -28,7 +28,6 @@ use Carbon\Carbon;
use Pterodactyl\Models; use Pterodactyl\Models;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Services\NotificationService;
class RemoteController extends Controller class RemoteController extends Controller
{ {
@ -42,7 +41,7 @@ class RemoteController extends Controller
public function postDownload(Request $request) public function postDownload(Request $request)
{ {
$download = Models\Download::where('token', $request->input('token', '00'))->first(); $download = Models\Download::where('token', $request->input('token'))->first();
if (! $download) { if (! $download) {
return response()->json([ return response()->json([
'error' => 'An invalid request token was recieved with this request.', 'error' => 'An invalid request token was recieved with this request.',
@ -59,18 +58,17 @@ class RemoteController extends Controller
public function postInstall(Request $request) public function postInstall(Request $request)
{ {
$server = Models\Server::where('uuid', $request->input('server'))->first(); $server = Models\Server::where('uuid', $request->input('server'))->with('node')->first();
if (! $server) { if (! $server) {
return response()->json([ return response()->json([
'error' => 'No server by that ID was found on the system.', 'error' => 'No server by that ID was found on the system.',
], 422); ], 422);
} }
$node = Models\Node::findOrFail($server->node_id);
$hmac = $request->input('signed'); $hmac = $request->input('signed');
$status = $request->input('installed'); $status = $request->input('installed');
if (base64_decode($hmac) !== hash_hmac('sha256', $server->uuid, $node->daemonSecret, true)) { if (base64_decode($hmac) !== hash_hmac('sha256', $server->uuid, $server->node->daemonSecret, true)) {
return response()->json([ return response()->json([
'error' => 'Signed HMAC was invalid.', 'error' => 'Signed HMAC was invalid.',
], 403); ], 403);
@ -86,17 +84,15 @@ class RemoteController extends Controller
public function event(Request $request) public function event(Request $request)
{ {
$server = Models\Server::where('uuid', $request->input('server'))->first(); $server = Models\Server::where('uuid', $request->input('server'))->with('node')->first();
if (! $server) { if (! $server) {
return response()->json([ return response()->json([
'error' => 'No server by that ID was found on the system.', 'error' => 'No server by that ID was found on the system.',
], 422); ], 422);
} }
$node = Models\Node::findOrFail($server->node_id);
$hmac = $request->input('signed'); $hmac = $request->input('signed');
if (base64_decode($hmac) !== hash_hmac('sha256', $server->uuid, $node->daemonSecret, true)) { if (base64_decode($hmac) !== hash_hmac('sha256', $server->uuid, $server->node->daemonSecret, true)) {
return response()->json([ return response()->json([
'error' => 'Signed HMAC was invalid.', 'error' => 'Signed HMAC was invalid.',
], 403); ], 403);
@ -130,7 +126,6 @@ class RemoteController extends Controller
$token->delete(); $token->delete();
// Manually as getConfigurationAsJson() returns it in correct format already // Manually as getConfigurationAsJson() returns it in correct format already
return response($node->getConfigurationAsJson(), 200) return response()->json($node->getConfigurationAsJson(), 200);
->header('Content-Type', 'application/json');
} }
} }