chore : simplify the installer User creation

This commit is contained in:
1Day 2022-02-09 07:54:03 +01:00
parent e30c947775
commit 068d1459a6
3 changed files with 17 additions and 34 deletions

1
.gitignore vendored
View file

@ -23,3 +23,4 @@ storage/app/public/logo.png
*vscode *vscode
- Kopie.env - Kopie.env
public/install/logs.txt public/install/logs.txt
install.lock

View file

@ -206,8 +206,6 @@ if (isset($_POST['createUser'])) {
} }
$name = $_POST['user'];
$mail = $_POST['email'];
$pteroID = $_POST['pteroID']; $pteroID = $_POST['pteroID'];
$pass = $_POST['pass']; $pass = $_POST['pass'];
$repass = $_POST['repass']; $repass = $_POST['repass'];
@ -231,9 +229,8 @@ if (isset($_POST['createUser'])) {
$result = json_decode($response, true); $result = json_decode($response, true);
curl_close($ch); // Close the connection curl_close($ch); // Close the connection
if (!$result["attributes"]["email"]) {
if ($result["attributes"]["email"] !== $mail) { header("LOCATION: index.php?step=6&message=Could not find the user with pterodactyl ID ".$pteroID);
header("LOCATION: index.php?step=6&message=The Email is not the same as the one used on Pterodactyl");
die(); die();
} }
if ($pass !== $repass) { if ($pass !== $repass) {
@ -241,6 +238,8 @@ if (isset($_POST['createUser'])) {
die(); die();
} }
$mail = $result["attributes"]["email"];
$name = $result["attributes"]["username"];
$pass = password_hash($pass, PASSWORD_DEFAULT); $pass = password_hash($pass, PASSWORD_DEFAULT);
$pteroURL = $pterobaseurl["value"] . "/api/application/users/" . $pteroID; $pteroURL = $pterobaseurl["value"] . "/api/application/users/" . $pteroID;
@ -269,11 +268,14 @@ if (isset($_POST['createUser'])) {
die(); die();
} }
$query1 = "INSERT INTO `" . getEnvironmentValue("DB_DATABASE") . "`.`users` (`name`, `role`, `credits`, `server_limit`, `pterodactyl_id`, `email`, `password`, `created_at`) VALUES ('$name', 'admin', '250', '1', '$pteroID', '$mail', '$pass', CURRENT_TIMESTAMP)"; $query1 = "INSERT INTO `" . getEnvironmentValue("DB_DATABASE") . "`.`users` (`name`, `role`, `credits`, `server_limit`, `pterodactyl_id`, `email`, `password`, `created_at`) VALUES ('$name', 'admin', '250', '1', '$pteroID', '$mail', '$pass', CURRENT_TIMESTAMP)";
if ($db->query($query1)) { if ($db->query($query1)) {
wh_log("[USER MAKER] Created user with Email ".$mail. " and pterodactyl ID ". $pteroID);
header("LOCATION: index.php?step=7"); header("LOCATION: index.php?step=7");
} else { } else {
wh_log($db->error); wh_log($db->error);

View file

@ -399,29 +399,18 @@ echo $cardheader;
<form method="POST" enctype="multipart/form-data" class="mb-3" <form method="POST" enctype="multipart/form-data" class="mb-3"
action="/install/forms.php" name="createUser"> action="/install/forms.php" name="createUser">
<div class="row"> <div class="form-group">
<div class="col-md-12"> <div class="custom-control mb-3">
<div class="form-group"> <label for="pteroID">Your Pterodactyl User-ID (found in the users-list on your pterodactyl dashboard)</label>
<div class="custom-control mb-3"> <input id="pteroID" name="pteroID" type="text"
<label for="user">Your Username</label> required
<input id="user" name="user" value="1" class="form-control">
type="text" required </div>
value="" class="form-control"> </div>
</div>
</div>
<div class="form-group">
<div class="custom-control mb-3">
<label for="email">Your Email Adress (used to Login)</label>
<input id="email" name="email"
type="text" required
value="" class="form-control">
</div>
</div>
<div class="form-group"> <div class="form-group">
<div class="custom-control mb-3"> <div class="custom-control mb-3">
<label for="pass">Password</label> <label for="pass">Password (this will be your new pterodactyl password aswell!)</label>
<input id="pass" name="pass" type="password" <input id="pass" name="pass" type="password"
required required
value="" minlength="8" class="form-control"> value="" minlength="8" class="form-control">
@ -436,15 +425,6 @@ echo $cardheader;
</div> </div>
</div> </div>
<div class="form-group">
<div class="custom-control mb-3">
<label for="pteroID">Your Pterodactyl User-ID</label>
<input id="pteroID" name="pteroID" type="text"
required
value="" class="form-control">
</div>
</div>
</div> </div>
<button class="btn btn-primary" name="createUser">Submit</button> <button class="btn btn-primary" name="createUser">Submit</button>