Skip to content
Snippets Groups Projects
Commit 9c5ac747 authored by Addin Munawwar's avatar Addin Munawwar
Browse files

feat: auth for book access

parent 3389d546
Branches
Tags
No related merge requests found
...@@ -38,13 +38,33 @@ ...@@ -38,13 +38,33 @@
$raw_data = file_get_contents("http://host.docker.internal:8040/api/curator-collection/$collectionId"); $raw_data = file_get_contents("http://host.docker.internal:8040/api/curator-collection/$collectionId");
$data = json_decode($raw_data, true); $data = json_decode($raw_data, true);
$books = $data['books']; $books = $data['books'];
echo json_encode($data);
require_once dirname(__DIR__) . '../../clients/SoapConsumer.php';
$soap = new SoapConsumer();
$username = $_SESSION['username'];
$soapData = $soap->getSubscriptionOf($username);
$subData = $soapData["Response"]["data"];
$subs = $subData["item"];
// check if user has subscribed to this curator, collectionId is in subs
$subscribed = false;
foreach ($subs as $sub) {
if ($sub["curator"] == $books[0]["curator"]) {
$subscribed = true;
break;
}
}
$link = $subscribed ? '<a href="/premium/book/' . $book['book_id'] .'">Details</a>' : "Subscribe to view details";
foreach (($books) as $index => $book) { foreach (($books) as $index => $book) {
echo "<tr>"; echo "<tr>";
echo "<td>" . $index+1 . "</td>"; echo "<td>" . $index+1 . "</td>";
echo "<td>" . $book['title'] . "</td>"; echo "<td>" . $book['title'] . "</td>";
echo "<td>" . $book['author'] . "</td>"; echo "<td>" . $book['author'] . "</td>";
echo '<td><a href="/premium/book/' . $book['book_id'] .'">Details</a></td>'; echo '<td>' . $link . '</td>';
echo "</tr>"; echo "</tr>";
} }
?> ?>
......
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
$raw_data = file_get_contents('http://host.docker.internal:8040/api/curator/' . $sub['curator']); $raw_data = file_get_contents('http://host.docker.internal:8040/api/curator/' . $sub['curator']);
$data = json_decode($raw_data, true); $data = json_decode($raw_data, true);
echo var_dump($data);
$colId = $data['collectionId']; $colId = $data['collectionId'];
echo "<tr>"; echo "<tr>";
......
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