From 307f3229d261e629b2901df2ec79c44b352e05e9 Mon Sep 17 00:00:00 2001 From: IceToast Date: Tue, 4 Apr 2023 01:23:44 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20external=5Fid=20already?= =?UTF-8?q?=20used=20#769?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Auth/RegisterController.php | 8 ++--- .../2023_04_03_231829_update_users_table.php | 32 +++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 database/migrations/2023_04_03_231829_update_users_table.php diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 6151a7fb..29a4b6e0 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -135,11 +135,12 @@ class RegisterController extends Controller 'server_limit' => $this->initial_server_limit, 'password' => Hash::make($data['password']), 'referral_code' => $this->createReferralCode(), + 'pterodactyl_id' => Str::uuid(), ]); $response = $this->pterodactyl->application->post('/application/users', [ - 'external_id' => App::environment('local') ? Str::random(16) : (string) $user->id, + 'external_id' => $user->pterodactyl_id, 'username' => $user->name, 'email' => $user->email, 'first_name' => $user->name, @@ -157,9 +158,8 @@ class RegisterController extends Controller ]); } - $user->update([ - 'pterodactyl_id' => $response->json()['attributes']['id'], - ]); + // delete activity log for user creation where description = 'created' or 'deleted' and subject_id = user_id + DB::table('activity_log')->where('description', 'created')->orWhere('description', 'deleted')->where('subject_id', $user->id)->delete(); //INCREMENT REFERRAL-USER CREDITS if (!empty($data['referral_code'])) { diff --git a/database/migrations/2023_04_03_231829_update_users_table.php b/database/migrations/2023_04_03_231829_update_users_table.php new file mode 100644 index 00000000..3caf98aa --- /dev/null +++ b/database/migrations/2023_04_03_231829_update_users_table.php @@ -0,0 +1,32 @@ +string('pterodactyl_id')->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->integer('pterodactyl_id')->nullable->change(); + }); + } +};