fix: user authentication interface

This commit is contained in:
karishmas6
2024-10-24 22:26:12 +05:30
parent 47e1e717e0
commit 7d37df74fe
10 changed files with 53 additions and 61 deletions

View File

@@ -1,7 +1,7 @@
/**
* RESTful API endpoints handling remote browser recording sessions.
*/
import { Router } from 'express';
import { Router, Request, Response } from 'express';
import {
initializeRemoteBrowserForRecording,
@@ -20,6 +20,11 @@ import { requireSignIn } from '../middlewares/auth';
export const router = Router();
chromium.use(stealthPlugin());
export interface AuthenticatedRequest extends Request {
user?: any;
}
/**
* Logs information about remote browser recording session.
*/
@@ -32,7 +37,10 @@ router.all('/', requireSignIn, (req, res, next) => {
* GET endpoint for starting the remote browser recording session.
* returns session's id
*/
router.get('/start', requireSignIn, async (req, res) => {
router.get('/start', requireSignIn, async (req: AuthenticatedRequest, res: Response) => {
if (!req.user) {
return res.status(401).send('User not authenticated');
}
const proxyConfig = await getDecryptedProxyConfig(req.user.id);
// Prepare the proxy options dynamically based on the user's proxy configuration
let proxyOptions: any = {}; // Default to no proxy