diff --git a/.gitignore b/.gitignore index 8c4bee2..84b4ab0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 -# User-specific stuff +# Group-specific stuff .idea/**/workspace.xml .idea/**/tasks.xml .idea/**/usage.statistics.xml diff --git a/Backend/Controllers/Admin/AdminLogin.php b/Backend/Controllers/Admin/AdminLogin.php new file mode 100644 index 0000000..e7e48eb --- /dev/null +++ b/Backend/Controllers/Admin/AdminLogin.php @@ -0,0 +1,36 @@ +password; + if(password_verify($password, $hashedPassword )){ + $_SESSION['userName'] = $userName; + $_SESSION['Admin'] = true; + $_SESSION['userId'] = $user->id; + $_SESSION['success'] = "You are now logged in"; + header('location: ../Frontend/index.php?login=success'); + }else{ + session_destroy(); + header('location: ../Frontend/index.php?login=failed?reason=password'); + } + + + } + else{ + session_destroy(); + header('location: ../Frontend/index.php?login=failed?reason=username'); + } + + +} \ No newline at end of file diff --git a/Backend/Controllers/Admin/NewGameJam.php b/Backend/Controllers/Admin/NewGameJam.php new file mode 100644 index 0000000..e9ce6fd --- /dev/null +++ b/Backend/Controllers/Admin/NewGameJam.php @@ -0,0 +1,21 @@ +name = $_POST["gameJam_name"]; + $gameJam->start_time = $_POST["start_time"]; + $gameJam->end_time = $_POST["end_time"]; + $gameJam->description = $_POST["description"]; + + if($gameJam->save()){ + + } + else{ + + } + } +} \ No newline at end of file diff --git a/Backend/Controllers/Admin/ResetPassword.php b/Backend/Controllers/Admin/ResetPassword.php index d931420..1513f73 100644 --- a/Backend/Controllers/Admin/ResetPassword.php +++ b/Backend/Controllers/Admin/ResetPassword.php @@ -9,7 +9,10 @@ if(isset($_SESSION['Admin'])){ if(isset($_POST['RestPassword'])){ $group = Group::find($_POST['groupId']); if($group){ - $group->password->password = password_hash("Aa123456&", PASSWORD_DEFAULT); + $group->password->password = password_hash($_POST['NewPassword'], PASSWORD_DEFAULT); + if($group->save()){ + + } } } } \ No newline at end of file diff --git a/Backend/Controllers/Admin/UpdateGameJam.php b/Backend/Controllers/Admin/UpdateGameJam.php new file mode 100644 index 0000000..ca0f843 --- /dev/null +++ b/Backend/Controllers/Admin/UpdateGameJam.php @@ -0,0 +1,27 @@ +name = $_POST['name']; + + $gameJam->start_time = $_POST['start_time']; + + $gameJam->end_time = $_POST['start_time']; + + if (!empty($_POST['key_word'])) { + $gameJam->key_word = $_POST['key_word']; + } + + $gameJam->description = $_POST['description']; + if ($gameJam->save()) { + + } + } + } + +} diff --git a/Backend/Controllers/GameJam/GetGameJam.php b/Backend/Controllers/GameJam/GetGameJam.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/Backend/Controllers/GameJam/GetGameJam.php @@ -0,0 +1 @@ +password->password; + if(password_verify($password, $hashedPassword )){ + $token = Str::random(100); + $grouppassword = Password::firstWhere('group_id', $group->id); + $grouppassword->remember_token = $token; + if($grouppassword->save()){ + $_SESSION['groupName'] = $groupName; + $_SESSION['token'] = $token; + $_SESSION['success'] = "You are now logged in"; + header('location: ../../../Frontend/index.php?login=success'); + } + else{ + session_destroy(); + header('location: ../../../Frontend/index.php?login=failed&?reason=token'); + } + + }else{ + session_destroy(); + header('location: ../../../Frontend/index.php?login=failed&?reason=password'); + } + + + } + else{ + session_destroy(); + header('location: ../../../Frontend/index.php?login=failed&?reason=group'); + } + + +} \ No newline at end of file diff --git a/Backend/Controllers/User/SigningUp.php b/Backend/Controllers/Group/SigningUp.php similarity index 80% rename from Backend/Controllers/User/SigningUp.php rename to Backend/Controllers/Group/SigningUp.php index f9c8e9e..e33e527 100644 --- a/Backend/Controllers/User/SigningUp.php +++ b/Backend/Controllers/Group/SigningUp.php @@ -5,6 +5,7 @@ require "../../../bootstrap.php"; use Backend\Models\Group; use Backend\Models\Password; use Backend\Models\GameJam; +use Illuminate\Support\Str; session_start(); @@ -33,12 +34,16 @@ if(isset($_POST['reg_group'])){ $password->password = password_hash($_POST['password'] ,PASSWORD_DEFAULT); + $token = Str::random(100); + + $password->remember_token = $token; + if(!$password->save()){ return; } $_SESSION['groupName'] = $groupName; - $_SESSION['groupId'] = $group->id; + $_SESSION['token'] = $token; $_SESSION['success'] = "You are now logged in"; - header('location: index.php'); + header('location: ../../../Frontend/index.php'); } diff --git a/Backend/Controllers/Group/UpdateGruop.php b/Backend/Controllers/Group/UpdateGruop.php new file mode 100644 index 0000000..84e763a --- /dev/null +++ b/Backend/Controllers/Group/UpdateGruop.php @@ -0,0 +1,24 @@ +password->remember_token === $_SESSION['token']){ + $group->group_name = $_POST['group_name']; + $group->group_amount = $_POST['group_amount']; + $group->game_jam_id = $_POST['game_jam_id']; + $group->save(); + } + } + + + + + + } + + + diff --git a/Backend/Controllers/User/logout.php b/Backend/Controllers/Group/logout.php similarity index 100% rename from Backend/Controllers/User/logout.php rename to Backend/Controllers/Group/logout.php diff --git a/Backend/Controllers/User/Login.php b/Backend/Controllers/User/Login.php deleted file mode 100644 index b5feeb5..0000000 --- a/Backend/Controllers/User/Login.php +++ /dev/null @@ -1,37 +0,0 @@ -password->password; - if(password_verify($password, $hashedPassword )){ - $_SESSION['groupName'] = $groupName; - $_SESSION['groupId'] = $group->id; - $_SESSION['success'] = "You are now logged in"; - header('location: ../Frontend/index.php?login=success'); - }else{ - session_destroy(); - header('location: ../Frontend/index.php?login=failed?reason=password'); - } - - - } - else{ - session_destroy(); - header('location: ../Frontend/index.php?login=failed?reason=group'); - } - - -} \ No newline at end of file diff --git a/composer.json b/composer.json index 1083192..ab3aec1 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "require": { - "illuminate/database": "^8.30" + "illuminate/database": "^8.30", }, "autoload": { "classmap": [ diff --git a/composer.lock b/composer.lock index da1aef9..428ee73 100644 --- a/composer.lock +++ b/composer.lock @@ -438,16 +438,16 @@ }, { "name": "nesbot/carbon", - "version": "2.45.1", + "version": "2.46.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "528783b188bdb853eb21239b1722831e0f000a8d" + "reference": "2fd2c4a77d58a4e95234c8a61c5df1f157a91bf4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/528783b188bdb853eb21239b1722831e0f000a8d", - "reference": "528783b188bdb853eb21239b1722831e0f000a8d", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/2fd2c4a77d58a4e95234c8a61c5df1f157a91bf4", + "reference": "2fd2c4a77d58a4e95234c8a61c5df1f157a91bf4", "shasum": "" }, "require": { @@ -527,7 +527,7 @@ "type": "tidelift" } ], - "time": "2021-02-11T18:30:17+00:00" + "time": "2021-02-24T17:30:44+00:00" }, { "name": "psr/container",