From b72009aa840cc64b6e6104f5686f8eeb6d200b05 Mon Sep 17 00:00:00 2001 From: 1Day Date: Mon, 27 Dec 2021 09:10:38 +0100 Subject: [PATCH] Added API Route --- app/Http/Controllers/Api/UserController.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index 07a7a698..e5fbd571 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -88,9 +88,24 @@ class UserController extends Controller "role" => ['sometimes', Rule::in(['admin', 'mod', 'client', 'member'])], ]); - $user->update($request->all()); - event(new UserUpdateCreditsEvent($user)); + + //Update Users Password on Pterodactyl + //Username,Mail,First and Lastname are required aswell + $response = Pterodactyl::client()->patch('/application/users/'.$user->pterodactyl_id, [ + "username" => $request->name, + "first_name" => $request->name, + "last_name" => $request->name, + "email" => $request->email, + + ]); + if ($response->failed()) { + throw ValidationException::withMessages([ + 'pterodactyl_error_message' => $response->toException()->getMessage(), + 'pterodactyl_error_status' => $response->toException()->getCode() + ]); + } + $user->update($request->all()); return $user; }