aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/utils.ts20
1 files changed, 19 insertions, 1 deletions
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts
index 9c08afb71..f326210f3 100644
--- a/server/helpers/utils.ts
+++ b/server/helpers/utils.ts
@@ -1,6 +1,8 @@
1import * as express from 'express' 1import * as express from 'express'
2import * as Promise from 'bluebird'
2 3
3import { pseudoRandomBytesPromise } from './core-utils' 4import { pseudoRandomBytesPromise } from './core-utils'
5import { CONFIG, database as db } from '../initializers'
4import { ResultList } from '../../shared' 6import { ResultList } from '../../shared'
5 7
6function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) { 8function badRequest (req: express.Request, res: express.Response, next: express.NextFunction) {
@@ -30,10 +32,26 @@ function getFormatedObjects<U, T extends FormatableToJSON> (objects: T[], object
30 return res 32 return res
31} 33}
32 34
35function isSignupAllowed () {
36 if (CONFIG.SIGNUP.ENABLED === false) {
37 return Promise.resolve(false)
38 }
39
40 // No limit and signup is enabled
41 if (CONFIG.SIGNUP.LIMIT === -1) {
42 return Promise.resolve(true)
43 }
44
45 return db.User.countTotal().then(totalUsers => {
46 return totalUsers < CONFIG.SIGNUP.LIMIT
47 })
48}
49
33// --------------------------------------------------------------------------- 50// ---------------------------------------------------------------------------
34 51
35export { 52export {
36 badRequest, 53 badRequest,
37 generateRandomString, 54 generateRandomString,
38 getFormatedObjects 55 getFormatedObjects,
56 isSignupAllowed
39} 57}