[3.0] Say a username is taken instead of erroring about it - #9483
Open
albertlast wants to merge 1 commit into
Open
[3.0] Say a username is taken instead of erroring about it#9483albertlast wants to merge 1 commit into
albertlast wants to merge 1 commit into
Conversation
The registration form asks whether a username is free as it is typed, and the answer for almost every name anybody tries is an error page. isReservedName() hands $fatal down to the two checks that look for an existing member or membergroup of a similar name, so those die instead of returning true. 2.1 asked the members table in the same place and only ever returned. Two things follow from that: The availability check answers `?action=signup;sa=usernamecheck;xml` with the fatal error page rather than <username valid="0">, writes a row to the error log for each one, and the callback that reads the response finds no <username> element in it and throws. And Profile.php returns 'name_taken' when a display name is in use, which is dead code: isReservedName() has already ended the request, with the wrong words, before the return is reached. validateUsername() has the same shape one level up. $return_error is a promise to hand the problems back rather than die of them, so pass that on: without it a name on the admin's reserved list still ends the availability check with an error page. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
This was referenced Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The registration form asks whether a username is free as it is typed. For almost
every name anybody actually tries, the answer is an error page.
On
release-3.0,?action=signup;sa=usernamecheck;xml:zzznewuser<username valid="1">Guest<username valid="0">testmember(an existing member)Administrator(a membergroup)Webmaster(on the reserved list)Each one also writes a row to
smf_log_errors, so a busy registration page fillsthe error log with ordinary typing. And
checkUsernameCallback()readsXMLDoc.getElementsByTagName("username")[0], which isundefinedwhen the bodyis HTML, so the check throws and the icon never updates either.
Why.
Security::isReservedName()passes$fataldown to the two checks thatlook for an existing member or membergroup with a similar name:
2.1 asked the members table in that same spot and only ever returned
true—its
$fatalbranches covered the reserved-word list, the censor and*, whichare things an admin forbade. "Somebody already has this name" is not one of
those, and every caller is asking about exactly that.
The same fault has a second symptom in the profile.
Profile.phphasreturn 'name_taken'is dead. Changing a display name to one already in use endsthe request with "contains the reserved name" — the wrong words as well as the
wrong shape — before the return is reached.
What changes
Those two checks report rather than die, so
isReservedName()answers thequestion it was asked and the callers phrase it. The reserved-word list, the
censor and
*still die when$fatalsays so.validateUsername()has the same shape one level up:$return_erroris apromise to hand the problems back, and the caller that asks for it wants XML, so
pass it on. Without that a name on the admin's reserved list still ends the
availability check with an error page.
Testing
Every row of the table above now returns
<username valid="0">orvalid="1">correctly, includingstar*nameand the empty string, with zeronew rows in
smf_log_errorsacross the whole run.Setting a display name to one in use now shows the inline field error "That
username/display name has already been taken" instead of a fatal page.
Submitting a registration with a reserved username still refuses it — now in the
form's error box rather than as an error page. A clean registration still
succeeds.
Issues References (Fixes|Related|Closes)
Related to #7933