Add maxLimit server configuration (#4048)

* Add maxLimit server configuration

* Fix maxlimit validation logic to correctly handle maxLimit:0 case
This commit is contained in:
Chris Norris
2017-10-02 06:23:09 -07:00
committed by Florent Vilmart
parent 976da4d715
commit 23bffc8883
7 changed files with 63 additions and 0 deletions

View File

@@ -71,6 +71,7 @@ export class Config {
this.mount = removeTrailingSlash(mount);
this.liveQueryController = cacheInfo.liveQueryController;
this.sessionLength = cacheInfo.sessionLength;
this.maxLimit = cacheInfo.maxLimit;
this.expireInactiveSessions = cacheInfo.expireInactiveSessions;
this.generateSessionExpiresAt = this.generateSessionExpiresAt.bind(this);
this.generateEmailVerifyTokenExpiresAt = this.generateEmailVerifyTokenExpiresAt.bind(this);
@@ -86,6 +87,7 @@ export class Config {
revokeSessionOnPasswordReset,
expireInactiveSessions,
sessionLength,
maxLimit,
emailVerifyTokenValidityDuration,
accountLockout,
passwordPolicy,
@@ -113,6 +115,8 @@ export class Config {
this.validateSessionConfiguration(sessionLength, expireInactiveSessions);
this.validateMasterKeyIps(masterKeyIps);
this.validateMaxLimit(maxLimit);
}
static validateAccountLockoutPolicy(accountLockout) {
@@ -220,6 +224,12 @@ export class Config {
}
}
static validateMaxLimit(maxLimit) {
if (maxLimit <= 0) {
throw 'Max limit must be a value greater than 0.'
}
}
generateEmailVerifyTokenExpiresAt() {
if (!this.verifyUserEmails || !this.emailVerifyTokenValidityDuration) {
return undefined;