X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fsignup.ts;h=7c73f7c5c02efcd8358a13bcef70a670e6c80baa;hb=26fb55bf37287afb37d8dc54ce5d03505cede8cf;hp=cdce7989d1842d0b331a3fe16197f939c42bacaf;hpb=06215f15e0a9fea2ef95b8b49cb2b5868fb64017;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/signup.ts b/server/helpers/signup.ts index cdce7989d..7c73f7c5c 100644 --- a/server/helpers/signup.ts +++ b/server/helpers/signup.ts @@ -1,21 +1,22 @@ -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) {