fix: 🐛 external_id already used #769

This commit is contained in:
IceToast 2023-04-04 01:23:44 +02:00
parent ce544019eb
commit 307f3229d2
No known key found for this signature in database
GPG key ID: 1464353E063A5B97
2 changed files with 36 additions and 4 deletions

View file

@ -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'])) {

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('pterodactyl_id')->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->integer('pterodactyl_id')->nullable->change();
});
}
};