Skip to content

Commit

Permalink
Adding auto user creation!
Browse files Browse the repository at this point in the history
  • Loading branch information
NaysKutzu committed Dec 8, 2022
1 parent b2a36b4 commit 1a34111
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion scripts/auth/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
$errors = array();
//IP,username,password,databasename
$db = mysqli_connect($_CONFIG["db_host"]. ':'. $_CONFIG["db_port"], $_CONFIG["db_username"], $_CONFIG["db_password"], $_CONFIG["db_name"]);
$getsettings = $db->query("SELECT * FROM settings")->fetch_array();

// REGISTER USER
if (isset($_POST['reg_user'])) {
$username = mysqli_real_escape_string($db, $_POST['username']);
Expand Down Expand Up @@ -36,7 +38,41 @@
mysqli_query($db, $query);
$_SESSION['username'] = $username;
$_SESSION['success'] = "You are now logged in";
header('location: index.php');
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $getsettings['panelurl']. "submitUserCreation");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);

curl_setopt($ch, CURLOPT_POST, TRUE);

curl_setopt($ch, CURLOPT_POSTFIELDS, "{
\"adminUser\": \"". $getsettings['paneladmusr_usr'] ."\",
\"adminPass\": \"".$getsettings['paneladmusr_pass']."\",
\"firstName\": \"".$_POST['name_first']."\",
\"lastName\": \"".$_POST['name_last']."\",
\"email\": \"".$_POST['email']."\",
\"userName\": \"".$_POST['username']."\",
\"password\": \"".$_POST['password']."\",
\"websitesLimit\": 0,
\"selectedACL\": \"user\",
\"securityLevel\": \"HIGH\"
}");

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json"
));

$response = curl_exec($ch);
curl_close($ch);
if ($response == 'string(57) "{"status": 1, "createStatus": 1, "error_message": "None"}"')
{
header('location: ../dashboard/index.php');
}
else
{
array_push($errors, "Faild to fetch the CyberPanel API");
}
}
}

Expand Down

0 comments on commit 1a34111

Please sign in to comment.