Skip to content
This repository was archived by the owner on Jul 20, 2026. It is now read-only.

Commit 0d49293

Browse files
Merge pull request #58 from TheRefraction/hotfix-auth
Authentication is fixed
2 parents f3b387e + 2aff260 commit 0d49293

3 files changed

Lines changed: 12 additions & 14 deletions

File tree

src/app/controllers/AuthController.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,19 @@ public function signIn() {
8888

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

91-
if ($user && password_verify($password, $user['password'])) {
92-
$_SESSION['user_id'] = $user['id'];
93-
$_SESSION['user_first_name'] = $user['first_name'];
94-
$_SESSION['user_last_name'] = $user['last_name'];
95-
$_SESSION['user_email'] = $user['email'];
96-
97-
$role = $this->accountModel->getAccountRole($user['id']);
91+
if ($user && password_verify($password, $user->password)) {
92+
$_SESSION['user_id'] = $user->id;
93+
$_SESSION['user_first_name'] = $user->first_name;
94+
$_SESSION['user_last_name'] = $user->last_name;
95+
$_SESSION['user_email'] = $user->email;
96+
$_SESSION['user_phone'] = $user->phone;
97+
98+
$role = $this->accountModel->getAccountRole($user->id);
9899
if ($role === 'admin') {
99100
header('Location: /admin');
100101
exit;
101102
}
102103

103-
$_SESSION['user_phone'] = $user['phone'];
104104
header('Location: /account');
105105
exit;
106106
}
@@ -161,6 +161,4 @@ public function updateAccount() {
161161
header('Location: /account');
162162
exit;
163163
}
164-
165-
166164
}

src/app/controllers/ProductController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function __construct(PDO $dbConnection) {
1111

1212
public function viewProducts() {
1313
$title = "View Products";
14-
$products = $this->productModel->getAll();
14+
$products = $this->productModel->getAllProducts();
1515
require_once __DIR__ . "/../views/products.php";
1616
}
1717

@@ -28,7 +28,7 @@ public function viewSingleProduct() {
2828
exit;
2929
}
3030

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

3333
if(!$product) {
3434
header('Location: /products');

src/app/views/product.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020
echo "
2121
<form method='POST' action='/cart'>
22-
<input type='hidden' name='product' value='" . $product . "'>
22+
<input type='hidden' name='product' value='" . $product->name . "'>
2323
<button type='submit' name='action' value='add'>Add to Cart</button>
2424
<button type='submit' name='action' value='remove'>Remove from Cart</button>
2525
<!-- Handle appearance of the button above with Js: make
@@ -28,4 +28,4 @@
2828
?>
2929
</main>
3030

31-
<?php include 'partials/footer.php'; ?>
31+
<?php include 'partials/footer.php'; ?>

0 commit comments

Comments
 (0)