aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-06-05 08:53:31 +0200
committerChocobozzz <me@florianbigard.com>2023-06-05 09:00:47 +0200
commit8715c76356f3f3a6bce29a65f08743a0aff6be69 (patch)
tree3e1120b5417e7c4d64bf2d5d2194623db84839ed
parentf5a12121fe3077648b0e875bb521f122e3d7f277 (diff)
downloadPeerTube-8715c76356f3f3a6bce29a65f08743a0aff6be69.tar.gz
PeerTube-8715c76356f3f3a6bce29a65f08743a0aff6be69.tar.zst
PeerTube-8715c76356f3f3a6bce29a65f08743a0aff6be69.zip
More specific message when signup is not allowed
-rw-r--r--server/lib/signup.ts6
-rw-r--r--server/middlewares/validators/user-registrations.ts2
2 files changed, 4 insertions, 4 deletions
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: {
15 const { signupMode } = options 15 const { signupMode } = options
16 16
17 if (CONFIG.SIGNUP.ENABLED === false) { 17 if (CONFIG.SIGNUP.ENABLED === false) {
18 return { allowed: false } 18 return { allowed: false, errorMessage: 'User registration is not allowed' }
19 } 19 }
20 20
21 if (signupMode === 'direct-registration' && CONFIG.SIGNUP.REQUIRES_APPROVAL === true) { 21 if (signupMode === 'direct-registration' && CONFIG.SIGNUP.REQUIRES_APPROVAL === true) {
22 return { allowed: false } 22 return { allowed: false, errorMessage: 'User registration requires approval' }
23 } 23 }
24 24
25 // No limit and signup is enabled 25 // No limit and signup is enabled
@@ -29,7 +29,7 @@ async function isSignupAllowed (options: {
29 29
30 const totalUsers = await UserModel.countTotal() 30 const totalUsers = await UserModel.countTotal()
31 31
32 return { allowed: totalUsers < CONFIG.SIGNUP.LIMIT } 32 return { allowed: totalUsers < CONFIG.SIGNUP.LIMIT, errorMessage: 'User limit is reached on this instance' }
33} 33}
34 34
35function isSignupAllowedForCurrentIP (ip: string) { 35function 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) {
59 if (allowedResult.allowed === false) { 59 if (allowedResult.allowed === false) {
60 return res.fail({ 60 return res.fail({
61 status: HttpStatusCode.FORBIDDEN_403, 61 status: HttpStatusCode.FORBIDDEN_403,
62 message: allowedResult.errorMessage || 'User registration is not enabled, user limit is reached or registration requires approval.' 62 message: allowedResult.errorMessage || 'User registration is not allowed'
63 }) 63 })
64 } 64 }
65 65