Game-Jaming/Backend/Controllers/Admin/AdminSignup.php

24 lines
600 B
PHP
Raw Normal View History

<?php
require_once "../../../bootstrap.php";
require_once "Admin.php";
use Backend\Models\AdminUser;
2021-04-19 07:15:15 +00:00
if (isAdmin()) {
if (isset($_POST["newAdmin"])) {
$admin = new AdminUser();
$admin->user_name = $_POST["newUsername"];
2021-04-26 06:21:51 +00:00
$admin->password = password_hash($_POST["newPassword"],PASSWORD_DEFAULT);
2021-04-19 07:15:15 +00:00
if ($admin->save()) {
2021-03-23 12:39:44 +00:00
http_response_code(201);
2021-04-19 07:15:15 +00:00
} else {
2021-03-23 12:39:44 +00:00
http_response_code(500);
}
2021-04-19 07:15:15 +00:00
} else {
2021-03-23 12:39:44 +00:00
http_response_code(400);
}
2021-04-19 07:15:15 +00:00
} else {
2021-03-23 12:39:44 +00:00
http_response_code(401);
echo json_encode(["message" => "is not admin"]);
}