feat: get user from req
This commit is contained in:
@@ -13,15 +13,21 @@ router.post('/config', requireSignIn, async (req: AuthenticatedRequest, res: Res
|
|||||||
const { server_url, username, password } = req.body;
|
const { server_url, username, password } = req.body;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!server_url) {
|
|
||||||
return res.status(400).send('Proxy URL is required');
|
|
||||||
}
|
|
||||||
|
|
||||||
const userId = 1;
|
if (!req.user) {
|
||||||
const user = await User.findByPk(userId);
|
return res.status(401).json({ ok: false, error: 'Unauthorized' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = await User.findByPk(req.user.id, {
|
||||||
|
attributes: { exclude: ['password'] },
|
||||||
|
});
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return res.status(404).send('User not found');
|
return res.status(404).json({ message: 'User not found' });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!server_url) {
|
||||||
|
return res.status(400).send('Proxy URL is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
let hashedProxyUsername: string | null = null;
|
let hashedProxyUsername: string | null = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user