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(); + }); + } +};