@@ -6,7 +6,10 @@ import AppCache from './cache';
6
6
import SchemaCache from './Controllers/SchemaCache' ;
7
7
import DatabaseController from './Controllers/DatabaseController' ;
8
8
import net from 'net' ;
9
- import { IdempotencyOptions } from './Options/Definitions' ;
9
+ import {
10
+ IdempotencyOptions ,
11
+ FileUploadOptions ,
12
+ } from './Options/Definitions' ;
10
13
11
14
function removeTrailingSlash ( str ) {
12
15
if ( ! str ) {
@@ -89,9 +92,7 @@ export class Config {
89
92
}
90
93
91
94
this . validateAccountLockoutPolicy ( accountLockout ) ;
92
-
93
95
this . validatePasswordPolicy ( passwordPolicy ) ;
94
-
95
96
this . validateFileUploadOptions ( fileUpload ) ;
96
97
97
98
if ( typeof revokeSessionOnPasswordReset !== 'boolean' ) {
@@ -247,28 +248,31 @@ export class Config {
247
248
throw 'You cannot use emailVerifyTokenReuseIfValid without emailVerifyTokenValidityDuration' ;
248
249
}
249
250
}
251
+
250
252
static validateFileUploadOptions ( fileUpload ) {
251
253
if ( ! fileUpload ) {
252
254
fileUpload = { } ;
253
255
}
254
- if (
255
- fileUpload . enableForAnonymousUser &&
256
- typeof fileUpload . enableForAnonymousUser !== 'boolean'
257
- ) {
258
- throw 'enableForAnonymousUser must be a boolean value' ;
256
+ if ( typeof fileUpload !== 'object' || fileUpload instanceof Array ) {
257
+ throw 'fileUpload must be an object value.' ;
259
258
}
260
-
261
- if ( fileUpload . enableForPublic && typeof fileUpload . enableForPublic !== 'boolean' ) {
262
- throw 'enableForPublic must be a boolean value' ;
259
+ if ( fileUpload . enableForAnonymousUser === undefined ) {
260
+ fileUpload . enableForAnonymousUser = FileUploadOptions . enableForAnonymousUser . default ;
261
+ } else if ( typeof fileUpload . enableForAnonymousUser !== 'boolean' ) {
262
+ throw 'fileUpload.enableForAnonymousUser must be a boolean value.' ;
263
263
}
264
-
265
- if (
266
- fileUpload . enableForAuthenticatedUser &&
267
- typeof fileUpload . enableForAuthenticatedUser !== 'boolean'
268
- ) {
269
- throw 'enableForAuthenticatedUser must be a boolean value' ;
264
+ if ( fileUpload . enableForPublic === undefined ) {
265
+ fileUpload . enableForPublic = FileUploadOptions . enableForPublic . default ;
266
+ } else if ( typeof fileUpload . enableForPublic !== 'boolean' ) {
267
+ throw 'fileUpload.enableForPublic must be a boolean value.' ;
268
+ }
269
+ if ( fileUpload . enableForAuthenticatedUser === undefined ) {
270
+ fileUpload . enableForAuthenticatedUser = FileUploadOptions . enableForAuthenticatedUser . default ;
271
+ } else if ( typeof fileUpload . enableForAuthenticatedUser !== 'boolean' ) {
272
+ throw 'fileUpload.enableForAuthenticatedUser must be a boolean value.' ;
270
273
}
271
274
}
275
+
272
276
static validateMasterKeyIps ( masterKeyIps ) {
273
277
for ( const ip of masterKeyIps ) {
274
278
if ( ! net . isIP ( ip ) ) {
0 commit comments