X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fsignup.ts;h=f19232621aa4e792db390d769cd11c2cb508ee4b;hb=e364e31e25bd1d4b8d801c845a96d6be708f0a18;hp=f094531eb721926431f9a17f7e80322d21eaebc9;hpb=bc48e33b80f357767b98c1d310b04bdda24c6d46;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/signup.ts b/server/lib/signup.ts index f094531eb..f19232621 100644 --- a/server/lib/signup.ts +++ b/server/lib/signup.ts @@ -4,11 +4,24 @@ import { UserModel } from '../models/user/user' const isCidr = require('is-cidr') -async function isSignupAllowed (): Promise<{ allowed: boolean, errorMessage?: string }> { +export type SignupMode = 'direct-registration' | 'request-registration' + +async function isSignupAllowed (options: { + signupMode: SignupMode + + ip: string // For plugins + body?: any +}): Promise<{ allowed: boolean, errorMessage?: string }> { + const { signupMode } = options + if (CONFIG.SIGNUP.ENABLED === false) { return { allowed: false } } + if (signupMode === 'direct-registration' && CONFIG.SIGNUP.REQUIRES_APPROVAL === true) { + return { allowed: false } + } + // No limit and signup is enabled if (CONFIG.SIGNUP.LIMIT === -1) { return { allowed: true }