Index tags, logout button

This commit is contained in:
TPD94 2025-04-30 04:42:47 -04:00
parent a74ba64696
commit c218ae4cc6
7 changed files with 47 additions and 12 deletions

View File

@ -12,8 +12,8 @@
<meta property='og:url' content="{{ data.opengraph_url }}" /> <meta property='og:url' content="{{ data.opengraph_url }}" />
<meta property='og:locale' content='en_US' /> <meta property='og:locale' content='en_US' />
<title>{{ data.tab_title }}</title> <title>{{ data.tab_title }}</title>
<script type="module" crossorigin src="/assets/index-CjVpgi8Q.js"></script> <script type="module" crossorigin src="/assets/index-C2DUB5KK.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DKsxfXVF.css"> <link rel="stylesheet" crossorigin href="/assets/index-BXlb7x7c.css">
</head> </head>
<body class="w-full h-full"> <body class="w-full h-full">
<div id="root" class="w-full h-full"></div> <div id="root" class="w-full h-full"></div>

View File

@ -5,15 +5,15 @@ function MyAccount() {
const [wvList, setWvList] = useState([]); const [wvList, setWvList] = useState([]);
const [prList, setPrList] = useState([]); const [prList, setPrList] = useState([]);
const [uploading, setUploading] = useState(false); const [uploading, setUploading] = useState(false);
const [username, setUsername] = useState(''); // <-- Added state for username const [username, setUsername] = useState('');
// Fetch user CDMs // Fetch user info
const fetchUserInfo = async () => { const fetchUserInfo = async () => {
try { try {
const response = await axios.post('/userinfo'); const response = await axios.post('/userinfo');
setWvList(response.data.Widevine_Devices || []); setWvList(response.data.Widevine_Devices || []);
setPrList(response.data.Playready_Devices || []); setPrList(response.data.Playready_Devices || []);
setUsername(response.data.Username || ''); // <-- Set username here setUsername(response.data.Username || '');
} catch (err) { } catch (err) {
console.error('Failed to fetch user info', err); console.error('Failed to fetch user info', err);
} }
@ -23,7 +23,7 @@ function MyAccount() {
fetchUserInfo(); fetchUserInfo();
}, []); }, []);
// Handle File Upload // Handle file upload
const handleUpload = async (event, cdmType) => { const handleUpload = async (event, cdmType) => {
const file = event.target.files[0]; const file = event.target.files[0];
if (!file) return; if (!file) return;
@ -49,20 +49,37 @@ function MyAccount() {
} }
}; };
// Handle logout
const handleLogout = async () => {
try {
await axios.post('/logout');
window.location.reload();
} catch (error) {
console.error('Logout failed:', error);
alert('Logout failed!');
}
};
return ( return (
<div id="myaccount" className="flex flex-row w-full min-h-full overflow-y-auto p-4"> <div id="myaccount" className="flex flex-row w-full min-h-full overflow-y-auto p-4">
<div className="flex flex-col w-full min-h-full lg:flex-row"> <div className="flex flex-col w-full min-h-full lg:flex-row">
{/* Left Panel */} {/* Left Panel */}
<div className="border-2 border-yellow-500/50 lg:h-full lg:w-96 w-full rounded-2xl p-4 flex flex-col items-center overflow-y-auto"> <div className="border-2 border-yellow-500/50 lg:h-full lg:w-96 w-full rounded-2xl p-4 flex flex-col items-center overflow-y-auto">
<h1 className="text-2xl font-bold text-white border-b-2 border-white p-2 w-full text-center"> <h1 className="text-2xl font-bold text-white border-b-2 border-white p-2 w-full text-center mb-2">
{username ? `${username}` : 'My Account'} {username ? `${username}` : 'My Account'}
</h1> </h1>
<button
onClick={handleLogout}
className="mt-auto w-full h-12 bg-yellow-500/50 rounded-2xl text-2xl text-white"
>
Log out
</button>
</div> </div>
{/* Right Panel */} {/* Right Panel */}
<div className="flex flex-col grow lg:ml-2 mt-2 lg:mt-0"> <div className="flex flex-col grow lg:ml-2 mt-2 lg:mt-0">
{/* Widevine Section */} {/* Widevine Section */}
<div className="border-2 border-yellow-500/50 flex flex-col w-full h-1/2 text-center rounded-2xl lg:p-4 p-2 overflow-y-auto"> <div className="border-2 border-yellow-500/50 flex flex-col w-full min-h-1/2 text-center rounded-2xl lg:p-4 p-2 overflow-y-auto">
<h1 className="text-2xl font-bold text-white border-b-2 border-white p-2">Widevine CDMs</h1> <h1 className="text-2xl font-bold text-white border-b-2 border-white p-2">Widevine CDMs</h1>
<div className="flex flex-col w-full grow p-2 bg-white/5 rounded-2xl mt-2 text-white text-left"> <div className="flex flex-col w-full grow p-2 bg-white/5 rounded-2xl mt-2 text-white text-left">
{wvList.length === 0 ? ( {wvList.length === 0 ? (
@ -92,7 +109,7 @@ function MyAccount() {
</div> </div>
{/* Playready Section */} {/* Playready Section */}
<div className="border-2 border-yellow-500/50 flex flex-col w-full h-1/2 text-center rounded-2xl p-2 mt-2 lg:mt-2 overflow-y-auto"> <div className="border-2 border-yellow-500/50 flex flex-col w-full min-h-1/2 text-center rounded-2xl p-2 mt-2 lg:mt-2 overflow-y-auto">
<h1 className="text-2xl font-bold text-white border-b-2 border-white p-2">Playready CDMs</h1> <h1 className="text-2xl font-bold text-white border-b-2 border-white p-2">Playready CDMs</h1>
<div className="flex flex-col w-full bg-white/5 grow rounded-2xl mt-2 text-white text-left p-2"> <div className="flex flex-col w-full bg-white/5 grow rounded-2xl mt-2 text-white text-left p-2">
{prList.length === 0 ? ( {prList.length === 0 ? (

View File

@ -34,5 +34,14 @@ tags = {
'opengraph_image': 'https://cdrm-project.com/og-api.jpg', 'opengraph_image': 'https://cdrm-project.com/og-api.jpg',
'opengraph_url': 'https://cdrm-project.com/api', 'opengraph_url': 'https://cdrm-project.com/api',
'tab_title': 'API', 'tab_title': 'API',
},
'account': {
'description': 'Account for CDRM-Project',
'keywords': 'Login, CDRM, CDM, CDRM-Project, register, account',
'opengraph_title': 'My account',
'opengraph_description': 'Account for CDRM-Project',
'opengraph_image': 'https://cdrm-project.com/og-home.jpg',
'opengraph_url': 'https://cdrm-project.com/account',
'tab_title': 'My account',
} }
} }

View File

@ -7,6 +7,7 @@ def check_for_config_file():
default_config = """\ default_config = """\
default_wv_cdm: '' default_wv_cdm: ''
default_pr_cdm: '' default_pr_cdm: ''
secret_key_flask: 'secretkey'
# change the type to mariadb to use mariadb below # change the type to mariadb to use mariadb below
database_type: 'sqlite' database_type: 'sqlite'
fqdn: '' fqdn: ''

View File

@ -12,9 +12,12 @@ from routes.upload import upload_bp
from routes.user_info import user_info_bp from routes.user_info import user_info_bp
from routes.register import register_bp from routes.register import register_bp
from routes.login import login_bp from routes.login import login_bp
import os
import yaml
app = Flask(__name__) app = Flask(__name__)
app.secret_key = 'TT' with open(f'{os.getcwd()}/configs/config.yaml', 'r') as file:
config = yaml.safe_load(file)
app.secret_key = config['secret_key_flask']
CORS(app) CORS(app)

View File

@ -30,3 +30,8 @@ def login_status():
return jsonify({'message': 'False'}) return jsonify({'message': 'False'})
except: except:
return jsonify({'message': 'False'}) return jsonify({'message': 'False'})
@login_bp.route('/logout', methods=['POST'])
def logout():
session.pop('username', None)
return jsonify({'message': 'Successfully logged out!'})

View File

@ -26,7 +26,7 @@ def index(path=''):
file_path = os.path.join(react_bp.static_folder, path) file_path = os.path.join(react_bp.static_folder, path)
if path != "" and os.path.exists(file_path): if path != "" and os.path.exists(file_path):
return send_from_directory(react_bp.static_folder, path) return send_from_directory(react_bp.static_folder, path)
elif path.lower() in ['', 'cache', 'api', 'testplayer']: elif path.lower() in ['', 'cache', 'api', 'testplayer', 'account']:
data = index_tags.tags.get(path.lower(), index_tags.tags['index']) data = index_tags.tags.get(path.lower(), index_tags.tags['index'])
return render_template('index.html', data=data) return render_template('index.html', data=data)
else: else: