more test

This commit is contained in:
lesion
2022-03-10 13:51:24 +01:00
parent 9a1f650a3b
commit 2fa24b9478
6 changed files with 61 additions and 18 deletions

View File

@@ -290,6 +290,13 @@ const eventController = {
res.sendStatus(200)
},
async isAnonEventAllowed (req, res, next) {
if (!res.locals.settings.allow_anon_event) {
return res.sendStatus(403)
}
next()
},
async add (req, res) {
// req.err comes from multer streaming error
if (req.err) {

View File

@@ -101,7 +101,7 @@ if (config.status !== 'READY') {
*/
// allow anyone to add an event (anon event has to be confirmed, TODO: flood protection)
api.post('/event', upload.single('image'), eventController.add)
api.post('/event', eventController.isAnonEventAllowed, upload.single('image'), eventController.add)
api.put('/event', isAuth, upload.single('image'), eventController.update)
api.get('/event/import', isAuth, helpers.importURL)