mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 03:06:31 -05:00
Rework error messages for image uploads
This patch reworks the error messages for image uploads to make more sense. Instead of using the current `formidable error` for everything, all custom error detection now provide the (hopefully) more useful `Image Upload error` prefix for error messages. Signed-off-by: Christoph Kern <sheogorath@shivering-isles.com>
This commit is contained in:
parent
d097211c54
commit
f83e4d66ed
1 changed files with 4 additions and 4 deletions
|
@ -21,16 +21,16 @@ imageRouter.post('/uploadimage', function (req, res) {
|
|||
|
||||
form.parse(req, function (err, fields, files) {
|
||||
if (err) {
|
||||
logger.error(`formidable error: ${err}`)
|
||||
logger.error(`Image upload error: formidable error: ${err}`)
|
||||
return errors.errorForbidden(res)
|
||||
} else if (!req.isAuthenticated() && !config.allowAnonymous && !config.allowAnonymousEdits) {
|
||||
logger.error(`formidable error: Anonymous edits and therefore uploads are not allowed)`)
|
||||
logger.error(`Image upload error: Anonymous edits and therefore uploads are not allowed)`)
|
||||
return errors.errorForbidden(res)
|
||||
} else if (!files.image || !files.image.path) {
|
||||
logger.error(`formidable error: Upload didn't contain file)`)
|
||||
logger.error(`Image upload error: Upload didn't contain file)`)
|
||||
return errors.errorBadRequest(res)
|
||||
} else if (!config.allowedUploadMimeTypes.includes(files.image.type)) {
|
||||
logger.error(`formidable error: MIME-type "${files.image.type}" of uploaded file not allowed, only "${config.allowedUploadMimeTypes.join(', ')}" are allowed)`)
|
||||
logger.error(`Image upload error: MIME-type "${files.image.type}" of uploaded file not allowed, only "${config.allowedUploadMimeTypes.join(', ')}" are allowed)`)
|
||||
return errors.errorBadRequest(res)
|
||||
} else {
|
||||
logger.debug(`SERVER received uploadimage: ${JSON.stringify(files.image)}`)
|
||||
|
|
Loading…
Reference in a new issue