Skip to content
Snippets Groups Projects
Commit 2abcb3d0 authored by Bitha17's avatar Bitha17
Browse files

fix auth bug and routing

parent fdffdbec
No related merge requests found
......@@ -68,6 +68,7 @@ class PembelianController {
public function handleRequest() {
if (isset($_GET['purchaseAction'])) {
if ($_GET['purchaseAction'] === 'purchaseTicket') {
unset($_GET['purchaseAction']);
$ticketId = $_POST['ticketId'];
$userId = $_POST['userId'];
$this->purchaseTicket($ticketId,$userId);
......
......@@ -58,6 +58,7 @@ class UserController {
}
public function logout() {
session_start();
if (isset($_SESSION["user_id"])) {
unset($_SESSION["user_id"]);
session_destroy();
......@@ -75,7 +76,7 @@ class UserController {
$password = $_POST['loginPassword'];
if (filter_var($emailOrUsername, FILTER_VALIDATE_EMAIL)){
if ($this->loginByEmail($emailOrUsername, $password) === "success") {
header("Location:/../../../home.php");
header("Location:Views/home/home.php");
ob_end_flush();
} else {
header("Location:Views/login/login.php");
......@@ -83,7 +84,7 @@ class UserController {
}
} else {
if ($this->loginByUsername($emailOrUsername,$password) === "success") {
header("Location:/../../../home.php");
header("Location:Views/home/home.php");
ob_end_flush();
} else {
header("Location:Views/login/login.php");
......@@ -106,7 +107,7 @@ class UserController {
ob_end_flush();
}
} elseif ($_POST['userAction'] === 'logout') {
echo "here";
unset($_POST['userAction']);
$this->logout();
header("Location:Views/login/login.php");
ob_end_flush();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment