en fil der tillader en admin at oprette en my admin

This commit is contained in:
Thomas FJ 2021-03-19 10:48:42 +01:00
parent c1484e4710
commit 409556ca2e
1 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,26 @@
<?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()){
header("location: ../../../Frontend/Html/AdminPage.html?success=adminUserWasCreated");
exit();
}else{
header("location: ../../../Frontend/Html/AdminPage.html?error=errorWhileSaving");
exit();
}
}else{
header("location: ../../../Frontend/Html/AdminPage.html?error=input:newAdmin.notSet");
exit();
}
}else{
header("location: ../../../Frontend/index.html?error=isNotAdministrator");
exit();
}