From fbdf9e675c871ad912f62f95d84e101ac595b1fe Mon Sep 17 00:00:00 2001 From: RundelhausCode Date: Tue, 9 Mar 2021 10:45:05 +0100 Subject: [PATCH] folder restrokteer --- .gitignore | 2 +- Backend/Controllers/Admin/AdminLogin.php | 36 +++++++++++++++++++ Backend/Controllers/Admin/NewGameJam.php | 21 +++++++++++ Backend/Controllers/Admin/ResetPassword.php | 5 ++- Backend/Controllers/Admin/UpdateGameJam.php | 27 ++++++++++++++ Backend/Controllers/GameJam/GetGameJam.php | 1 + Backend/Controllers/{User => Group}/Login.php | 0 .../Controllers/{User => Group}/SigningUp.php | 8 +++-- Backend/Controllers/Group/UpdateGruop.php | 15 ++++++++ .../Controllers/{User => Group}/logout.php | 0 composer.json | 3 +- 11 files changed, 113 insertions(+), 5 deletions(-) create mode 100644 Backend/Controllers/Admin/AdminLogin.php create mode 100644 Backend/Controllers/Admin/NewGameJam.php create mode 100644 Backend/Controllers/Admin/UpdateGameJam.php create mode 100644 Backend/Controllers/GameJam/GetGameJam.php rename Backend/Controllers/{User => Group}/Login.php (100%) rename Backend/Controllers/{User => Group}/SigningUp.php (81%) create mode 100644 Backend/Controllers/Group/UpdateGruop.php rename Backend/Controllers/{User => Group}/logout.php (100%) 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_hash($_POST['password'] ,PASSWORD_DEFAULT); + $token = OAuthProvider::generateToken(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..9726876 --- /dev/null +++ b/Backend/Controllers/Group/UpdateGruop.php @@ -0,0 +1,15 @@ +