feat: set raw true

This commit is contained in:
karishmas6
2024-10-26 19:29:30 +05:30
parent 701f0f3e57
commit 19d1b474ed

View File

@@ -96,25 +96,32 @@ router.get('/test', requireSignIn, async (req: AuthenticatedRequest, res: Respon
}); });
router.get('/config', requireSignIn, async (req: AuthenticatedRequest, res: Response) => { router.get('/config', requireSignIn, async (req: AuthenticatedRequest, res: Response) => {
try {
if (!req.user) { if (!req.user) {
return res.status(401).json({ ok: false, error: 'Unauthorized' }); return res.status(401).json({ ok: false, error: 'Unauthorized' });
} }
const user = await User.findByPk(req.user.id, { const user = await User.findByPk(req.user.id, {
attributes: ['proxy_url', 'proxy_username', 'proxy_password'], attributes: ['proxy_url', 'proxy_username', 'proxy_password'],
raw: true,
}); });
console.log(`found user:`, user);
if (!user) { if (!user) {
return res.status(404).json({ message: 'User not found' }); return res.status(404).json({ message: 'User not found' });
} }
const maskedProxyUrl = user.proxy_url ? maskProxyUrl(decrypt(user.proxy_url)) : null; const maskedProxyUrl = user.proxy_url ? maskProxyUrl(decrypt(user.proxy_url)) : null;
const auth = user.proxy_username && user.proxy_password ? true : false const auth = user.proxy_username && user.proxy_password ? true : false;
res.status(200).json({ res.status(200).json({
proxy_url: maskedProxyUrl, proxy_url: maskedProxyUrl,
auth: auth, auth: auth,
}); });
} catch (error) {
res.status(500).json({ ok: false, error: 'Could not retrieve proxy configuration' });
}
}); });
// delete proxy configuration // delete proxy configuration