From 58e194213f8ade1c0c9b5a41b47157f52f90423a Mon Sep 17 00:00:00 2001 From: Miniontoby <47940064+Miniontoby@users.noreply.github.com> Date: Sat, 24 Feb 2024 13:47:40 +0100 Subject: [PATCH 1/5] Add SingleSignOn method Added SingleSignOn method to allow "Login to Control Panel" button to work. This doesn't actually sign you on, since Pterodactyl doesn't support that, but it will redirect you to your panel link. Perfect for --- pterodactyl/pterodactyl.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pterodactyl/pterodactyl.php b/pterodactyl/pterodactyl.php index 12af1b6..3f15316 100644 --- a/pterodactyl/pterodactyl.php +++ b/pterodactyl/pterodactyl.php @@ -644,3 +644,23 @@ function pterodactyl_ClientArea(array $params) { // Ignore } } + +function pterodactyl_ServiceSingleSignOn(array $params) { + if($params['moduletype'] !== 'pterodactyl') return; + + try { + $hostname = pterodactyl_GetHostname($params); + $serverData = pterodactyl_GetServerID($params, true); + $response = $formattedResponse = array('redirectUrl' => $hostname . '/server/' . $serverData['attributes']['identifier']); + + $return = [ + 'success' => true, + 'redirectTo' => $response['redirectUrl'], + ]; + } catch (Exception $e) { + return [ + 'success' => false, + 'errorMsg' => $e->getMessage(), + ]; + } +} From 04ef5d4f025d5bfc22824ef7274c34c7a52c253c Mon Sep 17 00:00:00 2001 From: Miniontoby <47940064+Miniontoby@users.noreply.github.com> Date: Sat, 24 Feb 2024 13:50:11 +0100 Subject: [PATCH 2/5] Made it inline... --- pterodactyl/pterodactyl.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pterodactyl/pterodactyl.php b/pterodactyl/pterodactyl.php index 3f15316..fc45992 100644 --- a/pterodactyl/pterodactyl.php +++ b/pterodactyl/pterodactyl.php @@ -651,11 +651,10 @@ function pterodactyl_ServiceSingleSignOn(array $params) { try { $hostname = pterodactyl_GetHostname($params); $serverData = pterodactyl_GetServerID($params, true); - $response = $formattedResponse = array('redirectUrl' => $hostname . '/server/' . $serverData['attributes']['identifier']); $return = [ 'success' => true, - 'redirectTo' => $response['redirectUrl'], + 'redirectTo' => $hostname . '/server/' . $serverData['attributes']['identifier'], ]; } catch (Exception $e) { return [ From 1855622f4db0d3d5cada13055305c3cff7b8576d Mon Sep 17 00:00:00 2001 From: Miniontoby <47940064+Miniontoby@users.noreply.github.com> Date: Sat, 24 Feb 2024 13:52:44 +0100 Subject: [PATCH 3/5] Forgot to check if not 404 --- pterodactyl/pterodactyl.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pterodactyl/pterodactyl.php b/pterodactyl/pterodactyl.php index fc45992..5dacea0 100644 --- a/pterodactyl/pterodactyl.php +++ b/pterodactyl/pterodactyl.php @@ -651,10 +651,13 @@ function pterodactyl_ServiceSingleSignOn(array $params) { try { $hostname = pterodactyl_GetHostname($params); $serverData = pterodactyl_GetServerID($params, true); + $response = ['redirectUrl' => $hostname]; + if($serverData['status_code'] !== 404 && isset($serverData['attributes']['id'])) + $response['redirectUrl'] = $hostname . '/server/' . $serverData['attributes']['identifier']; $return = [ 'success' => true, - 'redirectTo' => $hostname . '/server/' . $serverData['attributes']['identifier'], + 'redirectTo' => $response['redirectUrl'], ]; } catch (Exception $e) { return [ From ec5b0bfc457e1096d31db4ad803b94eeb059d220 Mon Sep 17 00:00:00 2001 From: Miniontoby <47940064+Miniontoby@users.noreply.github.com> Date: Sat, 24 Feb 2024 14:28:25 +0100 Subject: [PATCH 4/5] Didn't see the $return instead of return --- pterodactyl/pterodactyl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pterodactyl/pterodactyl.php b/pterodactyl/pterodactyl.php index 5dacea0..eb55bc5 100644 --- a/pterodactyl/pterodactyl.php +++ b/pterodactyl/pterodactyl.php @@ -655,7 +655,7 @@ function pterodactyl_ServiceSingleSignOn(array $params) { if($serverData['status_code'] !== 404 && isset($serverData['attributes']['id'])) $response['redirectUrl'] = $hostname . '/server/' . $serverData['attributes']['identifier']; - $return = [ + return = [ 'success' => true, 'redirectTo' => $response['redirectUrl'], ]; From 1934609f116f4b72b08ad8575e5293249e8a3dd5 Mon Sep 17 00:00:00 2001 From: Miniontoby <47940064+Miniontoby@users.noreply.github.com> Date: Sat, 24 Feb 2024 14:32:04 +0100 Subject: [PATCH 5/5] Forgot the = --- pterodactyl/pterodactyl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pterodactyl/pterodactyl.php b/pterodactyl/pterodactyl.php index eb55bc5..9e15e05 100644 --- a/pterodactyl/pterodactyl.php +++ b/pterodactyl/pterodactyl.php @@ -655,7 +655,7 @@ function pterodactyl_ServiceSingleSignOn(array $params) { if($serverData['status_code'] !== 404 && isset($serverData['attributes']['id'])) $response['redirectUrl'] = $hostname . '/server/' . $serverData['attributes']['identifier']; - return = [ + return [ 'success' => true, 'redirectTo' => $response['redirectUrl'], ];