fix installer, new users get role
This commit is contained in:
parent
490bc64f41
commit
83d7590b60
|
@ -139,6 +139,8 @@ class RegisterController extends Controller
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$user->syncRoles(4);
|
||||||
|
|
||||||
$response = $this->pterodactyl->application->post('/application/users', [
|
$response = $this->pterodactyl->application->post('/application/users', [
|
||||||
'external_id' => $user->pterodactyl_id,
|
'external_id' => $user->pterodactyl_id,
|
||||||
'username' => $user->name,
|
'username' => $user->name,
|
||||||
|
|
|
@ -26,7 +26,7 @@ return new class extends Migration
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::table('users', function (Blueprint $table) {
|
Schema::table('users', function (Blueprint $table) {
|
||||||
$table->integer('pterodactyl_id')->nullable->change();
|
$table->integer('pterodactyl_id')->nullable()->change();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Artisan;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Artisan::call('db:seed', [
|
|
||||||
'--class' => 'PermissionsSeeder',
|
|
||||||
]);
|
|
||||||
|
|
||||||
Schema::table('users', function ($table) {
|
|
||||||
$table->dropColumn('role');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::table('users', function($table) {
|
|
||||||
$table->string('role')->default('member');
|
|
||||||
});
|
|
||||||
|
|
||||||
$users = User::with('roles')->get();
|
|
||||||
foreach($users as $user){
|
|
||||||
if($user->hasRole(1)){
|
|
||||||
$user->role = "admin";
|
|
||||||
}elseif ($user->hasRole(3)){
|
|
||||||
$user->role = "client";
|
|
||||||
}else{
|
|
||||||
$user->role = "member";
|
|
||||||
}
|
|
||||||
$user->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -32,9 +32,14 @@ class PermissionsSeeder extends Seeder
|
||||||
$admin->syncRoles(1);
|
$admin->syncRoles(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$admins = User::where("role","client")->get();
|
$mods = User::where("role","moderator")->get();
|
||||||
foreach($admins as $admin) {
|
foreach($mods as $mod) {
|
||||||
$admin->syncRoles(3);
|
$mod->syncRoles(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
$clients = User::where("role","client")->get();
|
||||||
|
foreach($clients as $client) {
|
||||||
|
$client->syncRoles(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
use PHPMailer\PHPMailer\Exception;
|
use PHPMailer\PHPMailer\Exception;
|
||||||
use PHPMailer\PHPMailer\PHPMailer;
|
use PHPMailer\PHPMailer\PHPMailer;
|
||||||
|
@ -77,6 +79,7 @@ if (isset($_POST['feedDB'])) {
|
||||||
$logs .= run_console('php artisan storage:link');
|
$logs .= run_console('php artisan storage:link');
|
||||||
$logs .= run_console('php artisan migrate --seed --force');
|
$logs .= run_console('php artisan migrate --seed --force');
|
||||||
$logs .= run_console('php artisan db:seed --class=ExampleItemsSeeder --force');
|
$logs .= run_console('php artisan db:seed --class=ExampleItemsSeeder --force');
|
||||||
|
$logs .= run_console('php artisan db:seed --class=PermissionsSeeder --force');
|
||||||
|
|
||||||
wh_log($logs, 'debug');
|
wh_log($logs, 'debug');
|
||||||
|
|
||||||
|
@ -292,8 +295,9 @@ if (isset($_POST['createUser'])) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$random = generateRandomString();
|
$random = generateRandomString();
|
||||||
$query1 = 'INSERT INTO `' . getenv('DB_DATABASE') . "`.`users` (`name`, `credits`, `server_limit`, `pterodactyl_id`, `email`, `password`, `created_at`, `referral_code`) VALUES ('$name', 'admin', '250', '1', '$pteroID', '$mail', '$pass', CURRENT_TIMESTAMP, '$random')";
|
|
||||||
$query2 = 'INSERT INTO `' . getenv('DB_DATABASE') . "`.`model_has_roles` (`role_id`, `model_type`, `model_id`) VALUES ('1', 'App\Models\User', '1')";
|
$query1 = 'INSERT INTO `' . getenv('DB_DATABASE') . "`.`users` (`name`, `role`, `credits`, `server_limit`, `pterodactyl_id`, `email`, `password`, `created_at`, `referral_code`) VALUES ('$name', 'admin', '250', '1', '$pteroID', '$mail', '$pass', CURRENT_TIMESTAMP, '$random')";
|
||||||
|
$query2 = "INSERT INTO `" . getenv('DB_DATABASE') . "`.`model_has_roles` (`role_id`, `model_type`, `model_id`) VALUES ('1', 'App\\\Models\\\User', '1')";
|
||||||
if ($db->query($query1) && $db->query($query2)) {
|
if ($db->query($query1) && $db->query($query2)) {
|
||||||
wh_log('Created user with Email ' . $mail . ' and pterodactyl ID ' . $pteroID, 'info');
|
wh_log('Created user with Email ' . $mail . ' and pterodactyl ID ' . $pteroID, 'info');
|
||||||
header('LOCATION: index.php?step=7');
|
header('LOCATION: index.php?step=7');
|
||||||
|
|
Loading…
Reference in a new issue