v0.1.5 Add the first support for create user account

This commit is contained in:
Victor
2021-06-09 11:13:12 +02:00
parent d0e2900941
commit b0fd4d4320
5 changed files with 17 additions and 13 deletions
+10 -10
View File
@@ -4,15 +4,15 @@ require "../../bootstrap.php";
use Backend\Model\Post;
if(isset($_POST['title'])){
//Create a new initialize
$post = new Post();
if(isset($_SESSION['permission'])){
$user = new Post();
$user->name = $_POST['name'];
$hashPass = password_hash($_POST['password'], PASSWORD_DEFAULT);
$user->password = $hashPass;
//Get the data from post and save it to the post model
$post->title = $_POST['title'];
$post->description = $_POST['description'];
//Call the save function.
if($post->save())
echo $post->id;
if(!$user->save()){
echo "Error";
}else{
echo "saved";
}
}
+3
View File
@@ -18,6 +18,9 @@ if (isset($_POST['loginsubmit'])) {
if ($password->save()) {
$_SESSION['token'] = $token;
$_SESSION['name'] = $username;
if($user->permission === 1){
$_SESSION['permission'] = $token;
}
header('location: ../../Frontend/admin.php?login=success');
exit();
http_response_code(200);