@@ -182,21 +182,25 @@ export class FilesRouter {
182182
183183 static _validateFileDownload ( req , config ) {
184184 const isMaster = req . auth ?. isMaster ;
185+ const isMaintenance = req . auth ?. isMaintenance ;
186+ if ( isMaster || isMaintenance ) {
187+ return ;
188+ }
185189 const user = req . auth ?. user ;
186190 const isLinked = user && Parse . AnonymousUtils . isLinked ( user ) ;
187- if ( ! isMaster && ! config . fileDownload . enableForAnonymousUser && isLinked ) {
191+ if ( ! config . fileDownload . enableForAnonymousUser && isLinked ) {
188192 throw new Parse . Error (
189193 Parse . Error . OPERATION_FORBIDDEN ,
190194 'File download by anonymous user is disabled.'
191195 ) ;
192196 }
193- if ( ! isMaster && ! config . fileDownload . enableForAuthenticatedUser && ! isLinked && user ) {
197+ if ( ! config . fileDownload . enableForAuthenticatedUser && ! isLinked && user ) {
194198 throw new Parse . Error (
195199 Parse . Error . OPERATION_FORBIDDEN ,
196200 'File download by authenticated user is disabled.'
197201 ) ;
198202 }
199- if ( ! isMaster && ! config . fileDownload . enableForPublic && ! user ) {
203+ if ( ! config . fileDownload . enableForPublic && ! user ) {
200204 throw new Parse . Error (
201205 Parse . Error . OPERATION_FORBIDDEN ,
202206 'File download by public is disabled.'
@@ -371,27 +375,30 @@ export class FilesRouter {
371375 return ;
372376 }
373377 const config = req . config ;
374- const user = req . auth . user ;
375378 const isMaster = req . auth . isMaster ;
376- const isLinked = user && Parse . AnonymousUtils . isLinked ( user ) ;
377- if ( ! isMaster && ! config . fileUpload . enableForAnonymousUser && isLinked ) {
378- next (
379- new Parse . Error ( Parse . Error . FILE_SAVE_ERROR , 'File upload by anonymous user is disabled.' )
380- ) ;
381- return ;
382- }
383- if ( ! isMaster && ! config . fileUpload . enableForAuthenticatedUser && ! isLinked && user ) {
384- next (
385- new Parse . Error (
386- Parse . Error . FILE_SAVE_ERROR ,
387- 'File upload by authenticated user is disabled.'
388- )
389- ) ;
390- return ;
391- }
392- if ( ! isMaster && ! config . fileUpload . enableForPublic && ! user ) {
393- next ( new Parse . Error ( Parse . Error . FILE_SAVE_ERROR , 'File upload by public is disabled.' ) ) ;
394- return ;
379+ const isMaintenance = req . auth . isMaintenance ;
380+ if ( ! isMaster && ! isMaintenance ) {
381+ const user = req . auth . user ;
382+ const isLinked = user && Parse . AnonymousUtils . isLinked ( user ) ;
383+ if ( ! config . fileUpload . enableForAnonymousUser && isLinked ) {
384+ next (
385+ new Parse . Error ( Parse . Error . FILE_SAVE_ERROR , 'File upload by anonymous user is disabled.' )
386+ ) ;
387+ return ;
388+ }
389+ if ( ! config . fileUpload . enableForAuthenticatedUser && ! isLinked && user ) {
390+ next (
391+ new Parse . Error (
392+ Parse . Error . FILE_SAVE_ERROR ,
393+ 'File upload by authenticated user is disabled.'
394+ )
395+ ) ;
396+ return ;
397+ }
398+ if ( ! config . fileUpload . enableForPublic && ! user ) {
399+ next ( new Parse . Error ( Parse . Error . FILE_SAVE_ERROR , 'File upload by public is disabled.' ) ) ;
400+ return ;
401+ }
395402 }
396403 const filesController = config . filesController ;
397404 const { filename } = req . params ;
0 commit comments