made some token work

This commit is contained in:
neerholt 2021-03-09 13:54:20 +01:00
parent ac6b5a6bd9
commit ff749d80d4
2 changed files with 61 additions and 52 deletions

View File

@ -1,6 +1,8 @@
<?php <?php
require_once "../../../bootstrap.php"; require_once "../../../bootstrap.php";
use Backend\Models\GameData; use Backend\Models\GameData;
use function Backend\Controllers\groupViaToken;
use Backend\Models\Group;
$isImages = false; $isImages = false;
@ -8,7 +10,10 @@ session_start();
if(isset($_SESSION['token'])){ if(isset($_SESSION['token'])){
if(isset($_POST['submitUpload'])){ $group = groupViaToken($_SESSION['token']);
if(!isset($group->game_data_id)){
if(isset($_POST['submitUpload'])){
//Get the data from the user form //Get the data from the user form
$gameFile = $_FILES['gameFile']; $gameFile = $_FILES['gameFile'];
$desc = $_POST['description']; $desc = $_POST['description'];
@ -58,6 +63,10 @@ if(isset($_POST['submitUpload'])){
$gameData->is_web_Based = $isWebBased; $gameData->is_web_Based = $isWebBased;
$gameData->save(); $gameData->save();
$group->gameData()->associate($gameData);
$group->save();
rename($gameFileTmp,"../../Games/".$gameFileNewName); rename($gameFileTmp,"../../Games/".$gameFileNewName);
if($isImages){ if($isImages){
rename($thumbnailFileTmp,"../../../Frontend/images/".$thumbnailFileNewName); rename($thumbnailFileTmp,"../../../Frontend/images/".$thumbnailFileNewName);
@ -71,6 +80,6 @@ if(isset($_POST['submitUpload'])){
echo "Wrong file type"; echo "Wrong file type";
} }
} }
}
} }

View File

@ -17,7 +17,7 @@ $gameJam = GameJam::firstOrCreate([
<title>HTML Tutorial</title> <title>HTML Tutorial</title>
<body> <body>
<form action="Controllers/User/SigningUp.php" method="POST"> <form action="Controllers/Group/SigningUp.php" method="POST">
<input type="text" name="groupName" placeholder="Group name"> <input type="text" name="groupName" placeholder="Group name">
<input type="number" name="groupAmount" placeholder="Group Amount"> <input type="number" name="groupAmount" placeholder="Group Amount">
<input type="number" name="gameJamId" placeholder="Game Jam id"> <input type="number" name="gameJamId" placeholder="Game Jam id">
@ -26,7 +26,7 @@ $gameJam = GameJam::firstOrCreate([
</form> </form>
<form action="Controllers/User/Login.php" method="POST"> <form action="Controllers/Group/Login.php" method="POST">
<input type="text" name="groupName" placeholder="Group name"> <input type="text" name="groupName" placeholder="Group name">
<input type="password" name="password" placeholder="password"> <input type="password" name="password" placeholder="password">
<input type="submit" name="login" value="login"> <input type="submit" name="login" value="login">