Spaces:
Sleeping
Sleeping
Nathan commited on
Commit ·
095dadd
1
Parent(s): 4913893
Fix: OAuth connection for multi-channel users
Browse filesFiles changed (2)
- Dockerfile+1-1
- server.js+27-28
1234FROM node:18-slim# Install FFmpeg for video processingRUN apt-get update && apt-get install -y ffmpeg python3 make g++1234FROM node:20-slim# Install FFmpeg for video processingRUN apt-get update && apt-get install -y ffmpeg python3 make g++
30 unmodified lines313233343536373839404142434445464748495051525314 unmodified lines68697071727374757677787980818283848530 unmodified lines// Serve static video filesapp.use('/videos', express.static(path.join(__dirname, 'output')));app.get('/api/videos', authenticateToken, async (req, res) => {try {const videoDir = path.join(__dirname, 'output');const files = await fs.readdir(videoDir);const videos = files.filter(f => f.endsWith('.mp4')).map(f => ({name: f,url: `/videos/${f}`,time: new Date() // Ideally we'd get file birthtime})).reverse();res.json(videos);} catch (e) {res.json([]);}});// JWT Middleware// Admin Authentication Middlewareconst authenticateAdmin = (req, res, next) => {authenticateToken(req, res, async () => {try {14 unmodified lines});};const authenticateToken = (req, res, next) => {const authHeader = req.headers['authorization'];const token = authHeader && authHeader.split(' ')[1];if (!token) return res.status(401).json({ error: 'Please login' });jwt.verify(token, JWT_SECRET, (err, user) => {if (err) return res.status(403).json({ error: 'Session expired' });req.userId = user.id;next();});};// --- OAuth2 Configuration ---async function getOAuth2Client(customClientId = null, customClientSecret = null) {30 unmodified lines313233343536373839404142434445464748495014 unmodified lines656667686970717273747576777879808182838430 unmodified lines// Serve static video filesapp.use('/videos', express.static(path.join(__dirname, 'output')));// JWT & Admin Middlewaresconst authenticateToken = (req, res, next) => {const authHeader = req.headers['authorization'];const token = authHeader && authHeader.split(' ')[1];if (!token) return res.status(401).json({ error: 'Please login' });jwt.verify(token, JWT_SECRET, (err, user) => {if (err) return res.status(403).json({ error: 'Session expired' });req.userId = user.id;next();});};const authenticateAdmin = (req, res, next) => {authenticateToken(req, res, async () => {try {14 unmodified lines});};app.get('/api/videos', authenticateToken, async (req, res) => {try {const videoDir = path.join(__dirname, 'output');const files = await fs.readdir(videoDir);const videos = files.filter(f => f.endsWith('.mp4')).map(f => ({name: f,url: `/videos/${f}`,time: new Date() // Ideally we'd get file birthtime})).reverse();res.json(videos);} catch (e) {res.json([]);}});// --- OAuth2 Configuration ---async function getOAuth2Client(customClientId = null, customClientSecret = null) {
Dockerfile+1-1
server.js+27-28