More specific message when signup is not allowed
This commit is contained in:
parent
f5a12121fe
commit
8715c76356
|
@ -15,11 +15,11 @@ async function isSignupAllowed (options: {
|
||||||
const { signupMode } = options
|
const { signupMode } = options
|
||||||
|
|
||||||
if (CONFIG.SIGNUP.ENABLED === false) {
|
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) {
|
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
|
// No limit and signup is enabled
|
||||||
|
@ -29,7 +29,7 @@ async function isSignupAllowed (options: {
|
||||||
|
|
||||||
const totalUsers = await UserModel.countTotal()
|
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) {
|
function isSignupAllowedForCurrentIP (ip: string) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ function ensureUserRegistrationAllowedFactory (signupMode: SignupMode) {
|
||||||
if (allowedResult.allowed === false) {
|
if (allowedResult.allowed === false) {
|
||||||
return res.fail({
|
return res.fail({
|
||||||
status: HttpStatusCode.FORBIDDEN_403,
|
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'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue