Skip to content

Commit

Permalink
feat: save setup file from web setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Moore committed Jul 13, 2023
1 parent 371d2f8 commit 9f810a8
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions backend/routers/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,18 @@ router.get('/', (req, res) => userConfigExists() ? res.redirect('/') : res.rende
router.get('/ui.js', (req, res) => userConfigExists() ? res.send('') : res.type('text').sendFile(path.join('dist-frontend/setup.mjs')));

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
a file system access
, but is not rate-limited.

// Setup route
router.post('/', BodyParserJson(), (req, res) => {
router.post('/', BodyParserJson(), async (req, res) => {
if (userConfigExists())
return res.status(409).json({ success: false, message: 'User config already exists' });

log.debug('Setup initiated');

// Parse body
try {
const confTest = new UserConfig(req.body as UserConfiguration);

// Temp logs
log.debug('Uploads dir', confTest.getConfig().uploadsDir);
log.debug('ID type', confTest.getConfig().idType);
log.debug('ID size', confTest.getConfig().idSize.toString());
log.debug('Gfy size', confTest.getConfig().gfySize.toString());
log.debug('Max file size', confTest.getConfig().maximumFileSize.toString());
// Parse body
const userConfig = new UserConfig(req.body as UserConfiguration);

// Save config
await userConfig.saveConfigFile();

return res.json({ success: true });
} catch (err: any) {
Expand Down

0 comments on commit 9f810a8

Please sign in to comment.