From 2df75ffbcbf6c8fb1e60a7e5deb164ca17c225be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andrej=20Rama=C5=A1euski?= <andrej@x2.cz>
Date: Sun, 1 Nov 2020 19:49:00 +0100
Subject: [PATCH] Korektnejsi prace s neprihlasenym

---
 lib/PiTube/Controller/Stream.pm | 6 +++++-
 templates/index.html.ep         | 4 ++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/PiTube/Controller/Stream.pm b/lib/PiTube/Controller/Stream.pm
index aabb5b0..6b1ffa2 100644
--- a/lib/PiTube/Controller/Stream.pm
+++ b/lib/PiTube/Controller/Stream.pm
@@ -25,7 +25,11 @@ sub list {
     STREAM:
     while ( my $stream = $streams->next()) {
 
-        my $rights = $c->session->{user}{acl}{ $stream->key } || next STREAM;
+        my $rights = $c->session->{user}{acl}{ $stream->key };
+
+        if ( ! $stream->is_public ) {
+            next STREAM if ! $rights;
+        }
 
         my %stream = (
             $stream->get_columns(),
diff --git a/templates/index.html.ep b/templates/index.html.ep
index 45a12ad..7086ef8 100644
--- a/templates/index.html.ep
+++ b/templates/index.html.ep
@@ -32,7 +32,11 @@ $('#Streams').bootstrapTable({
 });
 
 function streamInfoAllowed(index, row) {
+%   if ( $c->is_user_authenticated) {
     return row.is_live ? 0 : 1;
+%   } else {
+    return 0;
+%   }
 }
 
 function streamInfo(index, row, element) {
-- 
GitLab