From ee161812196bec1f13252a7290e9e3bc8d823e3e Mon Sep 17 00:00:00 2001 From: Aron Wiederkehr Date: Wed, 30 Apr 2025 15:57:47 +0200 Subject: [PATCH] refactor: Remove unused state and simplify sensitive info handling in modals --- frontend/src/components/TvPlaylistModal.tsx | 24 ++---- .../components/add_channel/ChannelModal.tsx | 80 ++----------------- .../add_channel/CustomHeaderInput.tsx | 9 +-- 3 files changed, 13 insertions(+), 100 deletions(-) diff --git a/frontend/src/components/TvPlaylistModal.tsx b/frontend/src/components/TvPlaylistModal.tsx index 41ffbdf..36ecbd0 100644 --- a/frontend/src/components/TvPlaylistModal.tsx +++ b/frontend/src/components/TvPlaylistModal.tsx @@ -1,5 +1,5 @@ -import { X, Copy, Tv2, Eye, EyeOff } from 'lucide-react'; -import { useContext, useState } from 'react'; +import { X, Copy, Tv2 } from 'lucide-react'; +import { useContext } from 'react'; import { ToastContext } from './notifications/ToastContext'; interface TvPlaylistModalProps { @@ -11,7 +11,6 @@ interface TvPlaylistModalProps { function TvPlaylistModal({ isOpen, onClose, isAdmin = false }: TvPlaylistModalProps) { const { addToast } = useContext(ToastContext); const playlistUrl = `${import.meta.env.VITE_BACKEND_URL || window.location.origin}/api/channels/playlist`; - const [showHiddenInfo, setShowHiddenInfo] = useState(false); if (!isOpen) return null; @@ -73,26 +72,13 @@ function TvPlaylistModal({ isOpen, onClose, isAdmin = false }: TvPlaylistModalPr

Admin Information

-

- {showHiddenInfo ? ( - <> - This playlist contains the actual stream URLs. You can share a link to the - application with non-admin users, and they will be able to watch the streams - without seeing the actual stream URLs. - - ) : ( - 'Click "Show sensitive info" to view additional information about the playlist.' - )} + This playlist contains all stream URLs. You can share a link to the + application with other users, and they will be able to watch the streams + together with you.

diff --git a/frontend/src/components/add_channel/ChannelModal.tsx b/frontend/src/components/add_channel/ChannelModal.tsx index 64ef82b..f2d8263 100644 --- a/frontend/src/components/add_channel/ChannelModal.tsx +++ b/frontend/src/components/add_channel/ChannelModal.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect, useContext } from 'react'; -import { Plus, Trash2, X, Eye, EyeOff } from 'lucide-react'; +import { Plus, Trash2, X } from 'lucide-react'; import socketService from '../../services/SocketService'; import { CustomHeader, Channel, ChannelMode } from '../../types'; import CustomHeaderInput from './CustomHeaderInput'; @@ -16,7 +16,6 @@ function ChannelModal({ onClose, channel, isAdmin = false }: ChannelModalProps) const [type, setType] = useState<'channel' | 'playlist'>('playlist'); const [isEditMode, setIsEditMode] = useState(false); const [inputMethod, setInputMethod] = useState<'url' | 'text'>('url'); - const [showSensitiveInfo, setShowSensitiveInfo] = useState(false); const [name, setName] = useState(''); const [url, setUrl] = useState(''); @@ -173,32 +172,6 @@ function ChannelModal({ onClose, channel, isAdmin = false }: ChannelModalProps) onClose(); }; - // Obfuscate part of the URL to hide sensitive information - const getObfuscatedUrl = (fullUrl: string) => { - if (!fullUrl || showSensitiveInfo) return fullUrl; - - try { - const url = new URL(fullUrl); - // Hide username and password in URL if present - if (url.username || url.password) { - return fullUrl.replace(/\/\/([^:@]+:[^@]+@)/g, '//***:***@'); - } - - // Hide tokens or API keys in query params - if (url.search && (url.search.includes('token') || url.search.includes('key') || url.search.includes('password') || url.search.includes('auth'))) { - return `${url.origin}${url.pathname}?***hidden***`; - } - - return fullUrl; - } catch { - // If URL is malformed, just return a partially obfuscated string - if (fullUrl.length > 20) { - return fullUrl.substring(0, 10) + '...' + fullUrl.substring(fullUrl.length - 10); - } - return fullUrl; - } - }; - return (
@@ -255,25 +228,15 @@ function ChannelModal({ onClose, channel, isAdmin = false }: ChannelModalProps) -
setUrl(e.target.value)} className="w-full bg-gray-700 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Enter stream URL" required - readOnly={!showSensitiveInfo && url.length > 0} />
@@ -372,25 +335,15 @@ function ChannelModal({ onClose, channel, isAdmin = false }: ChannelModalProps) M3U Text -
setPlaylistUrl(e.target.value)} className="w-full bg-gray-700 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Enter M3U playlist URL" required={inputMethod === 'url'} - readOnly={!showSensitiveInfo && playlistUrl.length > 0} /> ) : ( @@ -413,25 +366,15 @@ function ChannelModal({ onClose, channel, isAdmin = false }: ChannelModalProps) M3U Text -