diff --git a/app/Classes/Pterodactyl.php b/app/Classes/Pterodactyl.php index f75a3062..eeb0e3a6 100644 --- a/app/Classes/Pterodactyl.php +++ b/app/Classes/Pterodactyl.php @@ -87,6 +87,33 @@ class Pterodactyl if ($response->failed()) throw self::getException("Failed to get nodes from pterodactyl - ", $response->status()); return $response->json()['data']; } + + /** + * @return mixed + * @throws Exception + * @description Returns the infos of a single node + */ + public static function getNode($id) { + try { + $response = self::client()->get('/application/nodes/' . $id); + } catch(Exception $e) { + throw self::getException($e->getMessage()); + } + if($response->failed()) throw self::getException("Failed to get node id " . $id . " - " . $response->status()); + return $response->json()['attributes']; + } + + + + public static function getServers() { + try { + $response = self::client()->get('/application/servers'); + } catch (Exception $e) { + throw self::getException($e->getMessage()); + } + if($response->failed()) throw self::getException("Failed to get list of servers - ", $response->status()); + return $response->json()['data']; + } /** * @return null diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 07540765..6e1c61ab 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -160,6 +160,17 @@ class UserController extends Controller $user->delete(); return redirect()->back()->with('success', __('user has been removed!')); } + /** + * Verifys the users email + * + * @param User $user + * @return RedirectResponse + */ + public function verifyEmail(Request $request, User $user) + { + $user->verifyEmail(); + return redirect()->back()->with('success', __('Email has been verified!')); + } /** * @param Request $request @@ -285,6 +296,7 @@ class UserController extends Controller $suspendText = $user->isSuspended() ? __("Unsuspend") : __("Suspend"); return ' +
diff --git a/app/Http/Controllers/ServerController.php b/app/Http/Controllers/ServerController.php index e5ead954..b77fb955 100644 --- a/app/Http/Controllers/ServerController.php +++ b/app/Http/Controllers/ServerController.php @@ -101,9 +101,31 @@ class ServerController extends Controller return redirect()->route('servers.index')->with('error', __('Server limit reached!')); } - // minimum credits + // minimum credits && Check for Allocation if (FacadesRequest::has("product")) { $product = Product::findOrFail(FacadesRequest::input("product")); + // Can we allocate the node? If not then error lol(I don't like overallocation) + $node = Pterodactyl::getNode(FacadesRequest::input('node')); + $nodeMem = $node['memory']; + $nodeDisk = $node['disk']; + $nodeName = $node['name']; + $currServers = Auth::user()->servers(); + $currMem = 0; + $currDisk = 0; + foreach($currServers as $currServer) { + $pteroServer = $currServer->getPterodactylServer(); + $psvAttr = $pteroServer['attributes']; + if($psvAttr['node'] != $node['id']) + continue; + $currMem += $psvAttr['limits']['memory']; + $currDisk += $psvAttr['limits']['disk']; + } + $currMem += $product->memory; + $currDisk += $product->disk; + if($currMem > $nodeMem || $currDisk > $nodeDisk) + return redirect()->route('servers.index')->with('error', "The node '" . $nodeName . "' doesn't have the required memory or disk left to allocate this product."); + + // Min. Credits if ( Auth::user()->credits < ($product->minimum_credits == -1 diff --git a/app/Models/User.php b/app/Models/User.php index 5f8af024..8d9c9848 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -259,4 +259,11 @@ class User extends Authenticatable implements MustVerifyEmail $status = str_replace(' ', '/', $status); return $status; } + + public function verifyEmail() + { + $this->forceFill([ + 'email_verified_at' => now(), + ])->save(); + } } diff --git a/public/install/index.php b/public/install/index.php index 562e4a3b..70a7fb18 100644 --- a/public/install/index.php +++ b/public/install/index.php @@ -448,7 +448,7 @@ echo $cardheader; ?>

All done!

You may navigate to your Dashboard now and log in!

- "> + "> diff --git a/resources/views/servers/settings.blade.php b/resources/views/servers/settings.blade.php index f7db9fd1..91b3997d 100644 --- a/resources/views/servers/settings.blade.php +++ b/resources/views/servers/settings.blade.php @@ -224,39 +224,39 @@