Added routes

This commit is contained in:
neerholt
2021-03-17 09:43:09 +01:00
parent 0d4f161a48
commit a84c7a9258
14 changed files with 148 additions and 54 deletions
+6 -4
View File
@@ -1,6 +1,6 @@
<?php
require_once "../../../bootstrap.php";
require "../../../bootstrap.php";
use Backend\Models\Group;
use Backend\Models\Password;
@@ -25,24 +25,26 @@ if(isset($_POST['login'])){
$_SESSION['groupName'] = $groupName;
$_SESSION['token'] = $token;
$_SESSION['success'] = "You are now logged in";
//header('location: ../../../Frontend/index.php?login=success');
echo "YES";
header('location: ../../../Frontend/index.php?login=success');
exit();
}
else{
session_destroy();
header('location: ../../../Frontend/index.php?login=failed&?reason=token');
exit();
}
}else{
session_destroy();
header('location: ../../../Frontend/index.php?login=failed&?reason=password');
exit();
}
}
else{
session_destroy();
header('location: ../../../Frontend/index.php?login=failed&?reason=group');
exit();
}
+10 -2
View File
@@ -12,11 +12,19 @@ if(isAdmin()){
$password->password = password_hash($_POST['newPassword'], PASSWORD_DEFAULT);
echo $password;
if(!$password->save()){
header("location: ../../../Frontend/Html/AdminPage.html?error=FailedSaveResetPassword");
exit();
}
}else{
header("location: ../../../Frontend/Html/AdminPage.html?success=SavedResetPassword");
exit();
}
}else{
header("location: ../../../Frontend/Html/AdminPage.html?error=FailedToResetPassword");
exit();
}
}else{
header("location: ../../../Frontend/index.html?error=NotAdmin");
exit();
}
+7 -2
View File
@@ -43,8 +43,13 @@ if(isset($_POST['regGroup'])){
$_SESSION['groupName'] = $groupName;
$_SESSION['token'] = $token;
$_SESSION['success'] = "You are now logged in";
header('location: ../../../Frontend/index.html');
header("location: ../../../Frontend/index.html?success=GroupRegister");
exit();
}else{
header("location: ../../../Frontend/index.html?error=CouldNotValidatePassword");
exit();
}
}else{
header("location: ../../../Frontend/index.html?error=FailedRegister");
exit();
}
@@ -11,8 +11,16 @@ if(isLogin()){
$group->group_amount = $_POST['groupAmount'];
$group->game_jam_id = $_POST['gameJamId'];
$group->save();
header("location: ../../../Frontend/index.html?success=YouHaveUpdated");
exit();
}
}else{
header("location: ../../../Frontend/index.html?error=CouldNotUpdate");
exit();
}
}else{
header("location: ../../../Frontend/index.html?error=NotLogin");
exit();
}
+14 -5
View File
@@ -4,11 +4,20 @@ require_once "Group.php";
use Backend\Models\Password;
if(isLogin()){
if(isset($_POST['updatePassword']))
$password = Password::firstWhere("group_id", groupViaToken($_SESSION["token"])->id);
if(passwordValidate($pass = $_POST['password'])){
$password->password = password_hash($pass,PASSWORD_DEFAULT);
$password->save();
if(isset($_POST['updatePassword'])){
$password = Password::firstWhere("group_id", groupViaToken($_SESSION["token"])->id);
if(passwordValidate($pass = $_POST['password'])){
$password->password = password_hash($pass,PASSWORD_DEFAULT);
$password->save();
header("location: ../../../Frontend/index.html?success=PasswordUpdated");
exit();
}
}else{
header("location: ../../../Frontend/index.html?error=CouldNotUpdated");
exit();
}
}else{
header("location: ../../../Frontend/index.html?error=NotLogin");
exit();
}