password reset, admin upadte and Camel case update

This commit is contained in:
2021-03-11 09:28:30 +01:00
parent 246cfad08a
commit a65e9ceec8
16 changed files with 117 additions and 60 deletions
+9
View File
@@ -0,0 +1,9 @@
<?php
/**
* @return bool
*/
function isAdmin(){
session_start();
return isset($_SESSION['admin']);
}
+4 -4
View File
@@ -1,12 +1,13 @@
<?php
require "../../../bootstrap.php";
require_once "../../../bootstrap.php";
require_once "Admin.php";
use Backend\Models\AdminUser;
//Start the php session
session_start();
if(isset($_POST['ALogin'])){
if(isset($_POST['aLogin'])){
$userName = $_POST["userName"];
$password = $_POST["password"];
@@ -16,8 +17,7 @@ if(isset($_POST['ALogin'])){
$hashedPassword = $user->password;
if(password_verify($password, $hashedPassword )){
$_SESSION['userName'] = $userName;
$_SESSION['Admin'] = true;
$_SESSION['userId'] = $user->id;
$_SESSION['admin'] = true;
$_SESSION['success'] = "You are now logged in";
header('location: ../Frontend/index.php?login=success');
}else{
+11 -6
View File
@@ -1,14 +1,19 @@
<?php
require "../../../bootstrap.php";
require_once "../../../bootstrap.php";
require_once "Admin.php";
use Backend\Models\GameJam;
if(isset($_SESSION['Admin'])){
if(isset($_POST['NewGameJam'])){
var_dump($_POST);
session_start();
if(isAdmin()){
if(isset($_POST['newGameJam'])){
$gameJam = New GameJam();
$gameJam->name = $_POST["gameJam_name"];
$gameJam->start_time = $_POST["start_time"];
$gameJam->end_time = $_POST["end_time"];
$gameJam->name = $_POST["gameJamName"];
$gameJam->start_time = $_POST["startDate"]."T".$_POST["startTime"];
$gameJam->end_time = $_POST["endDate"]."T".$_POST["endTime"];
$gameJam->description = $_POST["description"];
if($gameJam->save()){
+5 -4
View File
@@ -1,15 +1,16 @@
<?php
require "../../../bootstrap.php";
require_once "../../../bootstrap.php";
require_once "Admin.php";
use Backend\Models\Group;
use Backend\Models\Password;
session_start();
if(isset($_SESSION['Admin'])){
if(isset($_POST['RestPassword'])){
if(isAdmin()){
if(isset($_POST['restPassword'])){
$group = Group::find($_POST['groupId']);
if($group){
$group->password->password = password_hash($_POST['NewPassword'], PASSWORD_DEFAULT);
$group->password->password = password_hash($_POST['newPassword'], PASSWORD_DEFAULT);
if($group->save()){
}
+8 -7
View File
@@ -1,20 +1,21 @@
<?php
require "../../../bootstrap.php";
require_once "../../../bootstrap.php";
require_once "Admin.php";
use Backend\Models\GameJam;
if(isset($_SESSION['Admin'])){
if(isset($_POST['UpdateGameJam'])) {
$gameJam = GameJam::find($_POST['game_jam_id']);
if(isAdmin()){
if(isset($_POST['updateGameJam'])) {
$gameJam = GameJam::find($_POST['gameJamId']);
if($gameJam){
$gameJam->name = $_POST['name'];
$gameJam->start_time = $_POST['start_time'];
$gameJam->start_time = $_POST["startDate"]."T".$_POST["startTime"];
$gameJam->end_time = $_POST['start_time'];
$gameJam->end_time = $_POST["endDate"]."T".$_POST["endTime"];
if (!empty($_POST['key_word'])) {
$gameJam->key_word = $_POST['key_word'];
$gameJam->key_word = $_POST['keyWord'];
}
$gameJam->description = $_POST['description'];