Skip to content
Snippets Groups Projects
Commit afbb778a authored by Sami Spets's avatar Sami Spets
Browse files

waiting for merge

parent 26e6f2bf
Branches
Tags
No related merge requests found
Source diff could not be displayed: it is too large. Options to address this: view the blob.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
</a> </a>
</div> </div>
</div> </div>
<button style="padding-top: 150px; text-align: center" onclick="checkIfLoggedIn()"></button>
</body> </body>
<script src='./js/index.js'></script> <script src='./js/index.js'></script>
<script src='./js/lib/libde265.min.js'></script> <script src='./js/lib/libde265.min.js'></script>
......
...@@ -6,7 +6,7 @@ const checkIfLoggedIn = async () => { ...@@ -6,7 +6,7 @@ const checkIfLoggedIn = async () => {
//User has a token saved in the browser //User has a token saved in the browser
}else{ }else{
//validate that token //validate that token
const response = await fetch('http://localhost:8080/auth/validation', { const response = await fetch('http://localhost:8080/auth/validation/', {
method: 'POST', method: 'POST',
headers: {'Authorization': token} headers: {'Authorization': token}
}) })
...@@ -17,7 +17,7 @@ const checkIfLoggedIn = async () => { ...@@ -17,7 +17,7 @@ const checkIfLoggedIn = async () => {
/* /*
Most likely it will render a new HTML file Most likely it will render a new HTML file
*/ */
document.getElementById('container').innerHTML = "<p>Salainen sivu</p>" renderThumbnails()
} }
} }
} }
...@@ -33,6 +33,7 @@ const handleLogin = () => { ...@@ -33,6 +33,7 @@ const handleLogin = () => {
const getAvailableStreams = async () => { const getAvailableStreams = async () => {
const streamsInJson = await fetch('http://localhost:8080/streams'); const streamsInJson = await fetch('http://localhost:8080/streams');
const streams = await streamsInJson.json(); const streams = await streamsInJson.json();
console.log('AVAILABLE', streams)
return streams; return streams;
} }
...@@ -41,26 +42,26 @@ const getAvailableStreams = async () => { ...@@ -41,26 +42,26 @@ const getAvailableStreams = async () => {
//Creates thumbnail (image) for all available streams and adds them to div class='container' //Creates thumbnail (image) for all available streams and adds them to div class='container'
const renderThumbnails = async () => { const renderThumbnails = async () => {
// const thumbnails = getAvailableStreams(); const thumbnails = await getAvailableStreams();
// console.log('THUMBNAILS', thumbnails) console.log('THUMBNAILS', thumbnails)
const containerDiv = document.getElementById('container') const containerDiv = document.getElementById('container')
containerDiv.innerHTML = ''; containerDiv.innerHTML = '';
console.log(containerDiv) console.log(containerDiv)
for(var i=0; i<2; i++){ for(var i=0; i<thumbnails.length; i++){
// const encodedURI = encodeURIComponent(thumbnails[i]) const encodedURI = encodeURIComponent(thumbnails[i])
// try{ try{
// const someData = await fetch(`http://localhost:8080/stream/rgb?uri=${encodedURI}`) const someData = await fetch(`http://localhost:8080/stream/rgb?uri=${encodedURI}`)
// console.log('SOME DATA', someData) console.log('SOME DATA', someData)
// if(!someData.ok){ if(!someData.ok){
// throw new Error('Image not found') throw new Error('Image not found')
// } }
// const myBlob = await someData.blob(); const myBlob = await someData.blob();
// const objectURL = URL.createObjectURL(myBlob); console.log('BLOB', myBlob)
// containerDiv.innerHTML += `<img src='${objectURL}' alt="Hups" width='500px'></img>` const objectURL = URL.createObjectURL(myBlob);
containerDiv.innerHTML += `<img src='https://via.placeholder.com/350x150' alt="Hups" width='350px'></img>` containerDiv.innerHTML += `<img src='${objectURL}' alt="Hups" width='500px'></img>`
// }catch(err){ }catch(err){
// console.log("Couldn't create thumbnail"); console.log("Couldn't create thumbnail");
// return return
// } }
} }
} }
\ No newline at end of file
...@@ -144,10 +144,12 @@ app.get('/', (req, res) => { ...@@ -144,10 +144,12 @@ app.get('/', (req, res) => {
}); });
app.post('/auth/validation', (req, res) => { app.post('/auth/validation', (req, res) => {
const token = req.headers.authorization.split(" ") const token = req.headers.authorization
const decoded = jwt.verify(token[1], keys.jwt.secret) const splitted = token.split(" ");
const decoded = jwt.verify(splitted[1], keys.jwt.secret)
console.log(decoded)
return res.status(200) return res.status(200).json("piippiip")
}) })
// app.get('/login/google', (req, res) => { // app.get('/login/google', (req, res) => {
// }) // })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment