Fix public access to private book view

This commit is contained in:
2025-11-27 09:27:40 +08:00
parent d850f54666
commit e51768622f
4 changed files with 19 additions and 9 deletions
+4 -1
View File
@@ -268,9 +268,12 @@ class BookController extends BaseController {
}
public function viewAll($id) {
$this->requireLogin();
$user_id = $_SESSION['user_id'];
$bookModel = new Book($this->pdo);
$chapterModel = new Chapter($this->pdo);
$book = $bookModel->findById($id);
$book = $bookModel->findByUserBook($id, $user_id);
if (!$book) {
http_response_code(404);
$this->render('errors/404');