feat: use authenticatedReq to query db
This commit is contained in:
@@ -22,7 +22,7 @@ router.post('/config', requireSignIn, async (req: Request, res: Response) => {
|
||||
return res.status(401).json({ ok: false, error: 'Unauthorized' });
|
||||
}
|
||||
|
||||
const user = await User.findByPk(req.user.id, {
|
||||
const user = await User.findByPk(authenticatedReq.user.id, {
|
||||
attributes: { exclude: ['password'] },
|
||||
});
|
||||
|
||||
@@ -65,7 +65,7 @@ router.get('/test', requireSignIn, async (req: Request, res: Response) => {
|
||||
return res.status(401).json({ ok: false, error: 'Unauthorized' });
|
||||
}
|
||||
|
||||
const user = await User.findByPk(req.user.id, {
|
||||
const user = await User.findByPk(authenticatedReq.user.id, {
|
||||
attributes: ['proxy_url', 'proxy_username', 'proxy_password'],
|
||||
raw: true
|
||||
});
|
||||
@@ -107,7 +107,7 @@ router.get('/config', requireSignIn, async (req: Request, res: Response) => {
|
||||
return res.status(401).json({ ok: false, error: 'Unauthorized' });
|
||||
}
|
||||
|
||||
const user = await User.findByPk(req.user.id, {
|
||||
const user = await User.findByPk(authenticatedReq.user.id, {
|
||||
attributes: ['proxy_url', 'proxy_username', 'proxy_password'],
|
||||
raw: true,
|
||||
});
|
||||
@@ -134,7 +134,7 @@ router.delete('/config', requireSignIn, async (req: Request, res: Response) => {
|
||||
return res.status(401).json({ ok: false, error: 'Unauthorized' });
|
||||
}
|
||||
|
||||
const user = await User.findByPk(req.user.id);
|
||||
const user = await User.findByPk(authenticatedReq.user.id);
|
||||
|
||||
if (!user) {
|
||||
return res.status(404).json({ message: 'User not found' });
|
||||
|
||||
Reference in New Issue
Block a user