fix: 🐛 external_id already used #769
This commit is contained in:
parent
ce544019eb
commit
307f3229d2
|
@ -135,11 +135,12 @@ class RegisterController extends Controller
|
||||||
'server_limit' => $this->initial_server_limit,
|
'server_limit' => $this->initial_server_limit,
|
||||||
'password' => Hash::make($data['password']),
|
'password' => Hash::make($data['password']),
|
||||||
'referral_code' => $this->createReferralCode(),
|
'referral_code' => $this->createReferralCode(),
|
||||||
|
'pterodactyl_id' => Str::uuid(),
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = $this->pterodactyl->application->post('/application/users', [
|
$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,
|
'username' => $user->name,
|
||||||
'email' => $user->email,
|
'email' => $user->email,
|
||||||
'first_name' => $user->name,
|
'first_name' => $user->name,
|
||||||
|
@ -157,9 +158,8 @@ class RegisterController extends Controller
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->update([
|
// delete activity log for user creation where description = 'created' or 'deleted' and subject_id = user_id
|
||||||
'pterodactyl_id' => $response->json()['attributes']['id'],
|
DB::table('activity_log')->where('description', 'created')->orWhere('description', 'deleted')->where('subject_id', $user->id)->delete();
|
||||||
]);
|
|
||||||
|
|
||||||
//INCREMENT REFERRAL-USER CREDITS
|
//INCREMENT REFERRAL-USER CREDITS
|
||||||
if (!empty($data['referral_code'])) {
|
if (!empty($data['referral_code'])) {
|
||||||
|
|
32
database/migrations/2023_04_03_231829_update_users_table.php
Normal file
32
database/migrations/2023_04_03_231829_update_users_table.php
Normal 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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in a new issue