24 lines
600 B
PHP
24 lines
600 B
PHP
<?php
|
|
require_once "../../../bootstrap.php";
|
|
require_once "Admin.php";
|
|
|
|
use Backend\Models\AdminUser;
|
|
|
|
if (isAdmin()) {
|
|
if (isset($_POST["newAdmin"])) {
|
|
$admin = new AdminUser();
|
|
$admin->user_name = $_POST["newUsername"];
|
|
$admin->password = password_hash($_POST["newPassword"],PASSWORD_DEFAULT);
|
|
|
|
if ($admin->save()) {
|
|
http_response_code(201);
|
|
} else {
|
|
http_response_code(500);
|
|
}
|
|
} else {
|
|
http_response_code(400);
|
|
}
|
|
} else {
|
|
http_response_code(401);
|
|
echo json_encode(["message" => "is not admin"]);
|
|
} |