]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/signup.ts
add display of logs matching any state
[github/Chocobozzz/PeerTube.git] / server / helpers / signup.ts
index cdce7989d1842d0b331a3fe16197f939c42bacaf..d34ff2db5e30287889804dd224e0be5f32343de1 100644 (file)
@@ -1,26 +1,27 @@
-import { CONFIG } from '../initializers'
 import { UserModel } from '../models/account/user'
 import * as ipaddr from 'ipaddr.js'
+import { CONFIG } from '../initializers/config'
+
 const isCidr = require('is-cidr')
 
-async function isSignupAllowed () {
+async function isSignupAllowed (): Promise<{ allowed: boolean, errorMessage?: string }> {
   if (CONFIG.SIGNUP.ENABLED === false) {
-    return false
+    return { allowed: false }
   }
 
   // No limit and signup is enabled
   if (CONFIG.SIGNUP.LIMIT === -1) {
-    return true
+    return { allowed: true }
   }
 
   const totalUsers = await UserModel.countTotal()
 
-  return totalUsers < CONFIG.SIGNUP.LIMIT
+  return { allowed: totalUsers < CONFIG.SIGNUP.LIMIT }
 }
 
 function isSignupAllowedForCurrentIP (ip: string) {
   const addr = ipaddr.parse(ip)
-  let excludeList = [ 'blacklist' ]
+  const excludeList = [ 'blacklist' ]
   let matched = ''
 
   // if there is a valid, non-empty whitelist, we exclude all unknown adresses too