Skip to content

Commit c70d31c

Browse files
committed
More model updates.
1 parent 3b3002b commit c70d31c

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

app/Http/Controllers/Base/SecurityController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ public function disableTotp(Request $request)
118118

119119
public function revoke(Request $request, $id)
120120
{
121-
$session = Session::where('id', $id)->where('user_id', $request->user()->id)->firstOrFail();
122-
$session->delete();
121+
Session::where('user_id', $request->user()->id)->findOrFail($id)->delete();
123122

124123
return redirect()->route('account.security');
125124
}

app/Http/Controllers/Remote/RemoteController.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
use Pterodactyl\Models;
2929
use Illuminate\Http\Request;
3030
use Pterodactyl\Http\Controllers\Controller;
31-
use Pterodactyl\Services\NotificationService;
3231

3332
class RemoteController extends Controller
3433
{
@@ -42,7 +41,7 @@ public function __construct()
4241

4342
public function postDownload(Request $request)
4443
{
45-
$download = Models\Download::where('token', $request->input('token', '00'))->first();
44+
$download = Models\Download::where('token', $request->input('token'))->first();
4645
if (! $download) {
4746
return response()->json([
4847
'error' => 'An invalid request token was recieved with this request.',
@@ -59,18 +58,17 @@ public function postDownload(Request $request)
5958

6059
public function postInstall(Request $request)
6160
{
62-
$server = Models\Server::where('uuid', $request->input('server'))->first();
61+
$server = Models\Server::where('uuid', $request->input('server'))->with('node')->first();
6362
if (! $server) {
6463
return response()->json([
6564
'error' => 'No server by that ID was found on the system.',
6665
], 422);
6766
}
6867

69-
$node = Models\Node::findOrFail($server->node_id);
7068
$hmac = $request->input('signed');
7169
$status = $request->input('installed');
7270

73-
if (base64_decode($hmac) !== hash_hmac('sha256', $server->uuid, $node->daemonSecret, true)) {
71+
if (base64_decode($hmac) !== hash_hmac('sha256', $server->uuid, $server->node->daemonSecret, true)) {
7472
return response()->json([
7573
'error' => 'Signed HMAC was invalid.',
7674
], 403);
@@ -86,17 +84,15 @@ public function postInstall(Request $request)
8684

8785
public function event(Request $request)
8886
{
89-
$server = Models\Server::where('uuid', $request->input('server'))->first();
87+
$server = Models\Server::where('uuid', $request->input('server'))->with('node')->first();
9088
if (! $server) {
9189
return response()->json([
9290
'error' => 'No server by that ID was found on the system.',
9391
], 422);
9492
}
9593

96-
$node = Models\Node::findOrFail($server->node_id);
97-
9894
$hmac = $request->input('signed');
99-
if (base64_decode($hmac) !== hash_hmac('sha256', $server->uuid, $node->daemonSecret, true)) {
95+
if (base64_decode($hmac) !== hash_hmac('sha256', $server->uuid, $server->node->daemonSecret, true)) {
10096
return response()->json([
10197
'error' => 'Signed HMAC was invalid.',
10298
], 403);
@@ -130,7 +126,6 @@ public function getConfiguration(Request $request, $tokenString)
130126
$token->delete();
131127

132128
// Manually as getConfigurationAsJson() returns it in correct format already
133-
return response($node->getConfigurationAsJson(), 200)
134-
->header('Content-Type', 'application/json');
129+
return response()->json($node->getConfigurationAsJson(), 200);
135130
}
136131
}

0 commit comments

Comments
 (0)