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

23 lines
558 B
PHP
Raw Normal View History

<?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 = $_POST["newPassword"];
if ($admin->save()){
2021-03-23 12:39:44 +00:00
http_response_code(201);
}else{
2021-03-23 12:39:44 +00:00
http_response_code(500);
}
}else{
2021-03-23 12:39:44 +00:00
http_response_code(400);
}
}else{
2021-03-23 12:39:44 +00:00
http_response_code(401);
echo json_encode(["message" => "is not admin"]);
}