From 21b8b2c25018b8967b4bd510a2a3d72f9b969f37 Mon Sep 17 00:00:00 2001 From: Rob Swindell <rob@synchro.net> Date: Fri, 21 Jan 2022 22:47:30 -0800 Subject: [PATCH] Fix "Username already taken." validation error (could not happen) The system.check_name() check *also* verifies that the username is not already taken, so we must perform the matchuser() check first in order to get the appropriate error message here when trying to use an alias (username) that's already taken. --- webv4/root/api/register.ssjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webv4/root/api/register.ssjs b/webv4/root/api/register.ssjs index 6c694c5711..5c6068bf03 100644 --- a/webv4/root/api/register.ssjs +++ b/webv4/root/api/register.ssjs @@ -90,10 +90,10 @@ if (system.newuser_password !== '' && (!request.has_param('newuser-password') || reply.errors.push(locale.strings.api_register.error_bad_syspass); } -if (!valid_param('alias', MIN_ALIAS, LEN_ALIAS) || !system.check_name(clean_param('alias'))) { - reply.errors.push(locale.strings.api_register.error_invalid_alias); -} else if (system.matchuser(clean_param('alias')) > 0) { + if (system.matchuser(clean_param('alias')) > 0) { reply.errors.push(locale.strings.api_register.error_alias_taken); +} else if (!valid_param('alias', MIN_ALIAS, LEN_ALIAS) || !system.check_name(clean_param('alias'))) { + reply.errors.push(locale.strings.api_register.error_invalid_alias); } else { prepUser.alias = clean_param('alias'); prepUser.handle = clean_param('alias'); -- GitLab