diff --git a/src/web/controller/audio-file-controller.php b/src/web/controller/audio-file-controller.php index 241318f9e20cc5cd9bd00a0a0b807bcf137242fc..62466519f9417794bfa61650bca7364fce323596 100644 --- a/src/web/controller/audio-file-controller.php +++ b/src/web/controller/audio-file-controller.php @@ -1,7 +1,7 @@ <?php if ($_SERVER['REQUEST_METHOD'] == 'GET') { - $checkSubsUrl = 'http://node:3000/services/relaxed/subscription/'.$_GET['id']; + $checkSubsUrl = 'http://node:3000/services/relaxed/subscription/'.$_GET['accountId']; $checkSubsResp = file_get_contents($checkSubsUrl); $subsData = json_decode($checkSubsResp, true); diff --git a/src/web/presentation/account/login.php b/src/web/presentation/account/login.php index 1cd170514861958ec1de5e7a6583271cc0adbf2b..130ceeb25233e790c3edf760fa7e9b7a6126cd73 100644 --- a/src/web/presentation/account/login.php +++ b/src/web/presentation/account/login.php @@ -41,7 +41,8 @@ if ($_SERVER["REQUEST_METHOD"] == "GET") { if (isset($_GET['r'])) { $redirectLoc = $_GET['r']; } - header("Location: ".$redirectLoc, true, 303); + $accountId = authenticateToken($res); + header("Location: ".$redirectLoc.'?id='.$accountId, true, 303); exit(); } $errMsg = 'Invalid username or password.'; diff --git a/src/web/presentation/home/home.php b/src/web/presentation/home/home.php index fb2bd9808009765bf7e96c8f9378a999425cc11d..fb31d1de2ba4e858a84c8c4a97ab6fed19ac9e3a 100644 --- a/src/web/presentation/home/home.php +++ b/src/web/presentation/home/home.php @@ -17,4 +17,8 @@ $accountId = authenticateToken($_COOKIE['token']); // Get random songs $shownalbums = execSelect('SELECT * FROM album ORDER BY RANDOM() LIMIT 6', []); +if ($_GET['id']) { + $accountId = $_GET['id']; +} + require 'presentation/home/home.view.php'; \ No newline at end of file diff --git a/src/web/presentation/home/home.view.php b/src/web/presentation/home/home.view.php index 71a1fe591a06d77ad9499447c3dd1c2673d89470..45cd4467b5fe5b1a706aa90666d8b82ae5193565 100644 --- a/src/web/presentation/home/home.view.php +++ b/src/web/presentation/home/home.view.php @@ -11,6 +11,10 @@ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet"> <script type="text/javascript" src="presentation\home\js\home.js" defer></script> + $accountId + <script> + localStorage.setItem('id', '<?php echo $accountId;?>'); + </script> <title>Home</title> </head> <body> diff --git a/src/web/presentation/music/info/js/albumInfo.js b/src/web/presentation/music/info/js/albumInfo.js index ccec2ff4117e23812ecb276c4f9759f71612309c..0c8762cbd765ed4c49531e9ad18d1db22bf9c693 100644 --- a/src/web/presentation/music/info/js/albumInfo.js +++ b/src/web/presentation/music/info/js/albumInfo.js @@ -6,14 +6,16 @@ for (let item of listItems) { item.addEventListener('click', (e) => { e.preventDefault(); + let accountId = localStorage.getItem('id'); let id = item.id; let xhr = new XMLHttpRequest(); - const url = "/audio?id="+id + const url = "/audio?id="+id+"&accountId="+accountId xhr.open('GET', url, true) xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { + console.log(xhr.responseText) const audio = JSON.parse(xhr.responseText) if (audio.hasOwnProperty('ads')) { diff --git a/src/web/presentation/music/info/js/musicInfo.js b/src/web/presentation/music/info/js/musicInfo.js index 5ef2687065c0b7a09f51e3c87143c5261b7be8a4..d28b8a361aa2dd41c99cdcd1df122294c2e8feac 100644 --- a/src/web/presentation/music/info/js/musicInfo.js +++ b/src/web/presentation/music/info/js/musicInfo.js @@ -7,9 +7,10 @@ playButton && playButton.addEventListener("click", (e) => { e.preventDefault() const query = new URLSearchParams(window.location.search) + let accountId = localStorage.getItem('id'); const id = query.get("id") const xhr = new XMLHttpRequest() - const url = "/audio?id="+id + const url = "/audio?id="+id+"&accountId="+accountId xhr.open('GET', url, true) xhr.onreadystatechange = function() {