Skip to content
This repository was archived by the owner on Jul 20, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/app/controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@ public function signIn() {

$user = $this->accountModel->getAccountByEmail($email);

if ($user && password_verify($password, $user['password'])) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['user_first_name'] = $user['first_name'];
$_SESSION['user_last_name'] = $user['last_name'];
$_SESSION['user_email'] = $user['email'];

$role = $this->accountModel->getAccountRole($user['id']);
if ($user && password_verify($password, $user->password)) {
$_SESSION['user_id'] = $user->id;
$_SESSION['user_first_name'] = $user->first_name;
$_SESSION['user_last_name'] = $user->last_name;
$_SESSION['user_email'] = $user->email;
$_SESSION['user_phone'] = $user->phone;

$role = $this->accountModel->getAccountRole($user->id);
if ($role === 'admin') {
header('Location: /admin');
exit;
}

$_SESSION['user_phone'] = $user['phone'];
header('Location: /account');
exit;
}
Expand Down Expand Up @@ -161,6 +161,4 @@ public function updateAccount() {
header('Location: /account');
exit;
}


}
4 changes: 2 additions & 2 deletions src/app/controllers/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function __construct(PDO $dbConnection) {

public function viewProducts() {
$title = "View Products";
$products = $this->productModel->getAll();
$products = $this->productModel->getAllProducts();
require_once __DIR__ . "/../views/products.php";
}

Expand All @@ -28,7 +28,7 @@ public function viewSingleProduct() {
exit;
}

$product = $this->productModel->getById($id);
$product = $this->productModel->getProductById($id);

if(!$product) {
header('Location: /products');
Expand Down
4 changes: 2 additions & 2 deletions src/app/views/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
echo "
<form method='POST' action='/cart'>
<input type='hidden' name='product' value='" . $product . "'>
<input type='hidden' name='product' value='" . $product->name . "'>
<button type='submit' name='action' value='add'>Add to Cart</button>
<button type='submit' name='action' value='remove'>Remove from Cart</button>
<!-- Handle appearance of the button above with Js: make
Expand All @@ -28,4 +28,4 @@
?>
</main>

<?php include 'partials/footer.php'; ?>
<?php include 'partials/footer.php'; ?>