From: Chocobozzz Date: Mon, 5 Jun 2023 06:53:31 +0000 (+0200) Subject: More specific message when signup is not allowed X-Git-Tag: v5.2.0~39^2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=8715c76356f3f3a6bce29a65f08743a0aff6be69;p=github%2FChocobozzz%2FPeerTube.git More specific message when signup is not allowed --- diff --git a/server/lib/signup.ts b/server/lib/signup.ts index f19232621..6702c22cb 100644 --- a/server/lib/signup.ts +++ b/server/lib/signup.ts @@ -15,11 +15,11 @@ async function isSignupAllowed (options: { const { signupMode } = options if (CONFIG.SIGNUP.ENABLED === false) { - return { allowed: false } + return { allowed: false, errorMessage: 'User registration is not allowed' } } if (signupMode === 'direct-registration' && CONFIG.SIGNUP.REQUIRES_APPROVAL === true) { - return { allowed: false } + return { allowed: false, errorMessage: 'User registration requires approval' } } // No limit and signup is enabled @@ -29,7 +29,7 @@ async function isSignupAllowed (options: { const totalUsers = await UserModel.countTotal() - return { allowed: totalUsers < CONFIG.SIGNUP.LIMIT } + return { allowed: totalUsers < CONFIG.SIGNUP.LIMIT, errorMessage: 'User limit is reached on this instance' } } function isSignupAllowedForCurrentIP (ip: string) { diff --git a/server/middlewares/validators/user-registrations.ts b/server/middlewares/validators/user-registrations.ts index fcf655a2c..47397391b 100644 --- a/server/middlewares/validators/user-registrations.ts +++ b/server/middlewares/validators/user-registrations.ts @@ -59,7 +59,7 @@ function ensureUserRegistrationAllowedFactory (signupMode: SignupMode) { if (allowedResult.allowed === false) { return res.fail({ status: HttpStatusCode.FORBIDDEN_403, - message: allowedResult.errorMessage || 'User registration is not enabled, user limit is reached or registration requires approval.' + message: allowedResult.errorMessage || 'User registration is not allowed' }) }