Use Agent.handleError in case checkAuth produces an error

This commit is contained in:
Shane Kilkelly 2018-05-25 16:01:11 +01:00
parent 0802403ee5
commit c8a8fe6af7

View file

@ -24,8 +24,8 @@ module.exports = LinkedFilesController = {
linkedFileData = Agent.sanitizeData(data) linkedFileData = Agent.sanitizeData(data)
linkedFileData.provider = provider linkedFileData.provider = provider
Agent.checkAuth project_id, data, user_id, (err, allowed) -> Agent.checkAuth project_id, data, user_id, (err, allowed) ->
return next(err) if err? return Agent.handleError(err, req, res, next) if err?
return ses.sendStatus(403) if !allowed return res.sendStatus(403) if !allowed
Agent.writeIncomingFileToDisk project_id, linkedFileData, user_id, (error, fsPath) -> Agent.writeIncomingFileToDisk project_id, linkedFileData, user_id, (error, fsPath) ->
if error? if error?
logger.error {err: error, project_id, name, linkedFileData, parent_folder_id, user_id}, 'error writing linked file to disk' logger.error {err: error, project_id, name, linkedFileData, parent_folder_id, user_id}, 'error writing linked file to disk'